Szerző Téma: Jármű nevek  (Megtekintve 897 alkalommal)

Nem elérhető myke

  • 213
    • Profil megtekintése
Jármű nevek
« Dátum: 2014. november 17. - 20:35:44 »
0 Show voters
Hali!
Hogy tudnám megcsinálni, hogy az adott (/vspawn) parancsnál nem kocsi ID-t kelljen beírni, hanem kocsi nevet? (Pl.: nem \"560\"-at írok be, hanem azt, hogy \"sultan\")
 
CMD:vspawn(playerid,params[])
{
if(IsPlayerAdmin(playerid) || pInfo[playerid][pAdmin] >= 5)
{
new model, szin1, szin2;
new ss[512];
if(sscanf(params,\"ddd\",model, szin1, szin2)) return SendClientMessage(playerid,0xffbf00AA,\"Használat: {ffffff}/vspawn [kocsimodell] [szín1] [szín2]\");
if(model >= 400 && 611 >= model)
{
    new i_Vehicle;
   new Float:px, Float:py, Float:pz;
   GetPlayerPos(playerid,px,py,pz);
   i_Vehicle = CreateVehicle(model,px,py,pz,0,szin1,szin2,0);
   format(ss,sizeof(ss),\"Jármű lehívva! Model: %d, Szín1: %i, Szín2: %i\",model,szin1,szin2);
   SendClientMessage(playerid,-1,ss);
      vInfo[ i_Vehicle ][ X ] = px;
   vInfo[ i_Vehicle ][ Y ] = py;
   vInfo[ i_Vehicle ][ Z ] = pz;
   vInfo[ i_Vehicle ][ A ] = 0;
   vInfo[ i_Vehicle ][ COLOR ] = szin1;
   vInfo[ i_Vehicle ][ COLOR2 ] = szin2;
   vInfo[ i_Vehicle ][ SOLD ] = 1;
           vInfo[ i_Vehicle ][ PLATE ] = GenerateRandomPlate( );
           vInfo[ i_Vehicle ][ PRICE ] = 0;
           vInfo[ i_Vehicle ][ MODEL ] = model;
           vInfo[ i_Vehicle ][ PAINTJOB ] = 3;
           vInfo[ i_Vehicle ][ KINEZET ] = 0;
           vInfo[ i_Vehicle ][ NEON ] = 0;
   if(!dini_Exists(vehicleFile(i_Vehicle)) )
   {
       dini_Create( vehicleFile(i_Vehicle) );
   }
            MilyenUzemAnyag(i_Vehicle);
   SaveVehicle(i_Vehicle);
   ReloadVehicle( i_Vehicle );
}else SendClientMessage(playerid,PIROS,\"A model ID-nek 400 és 611 között kell lennie.\");
    }else SendClientMessage(playerid,PIROS,\"Nincs kellő Admin szinted!\");
return 1;
}

 
UI.: GetVehicleModelName függvény:
 
stock GetVehicleModelName( modell )
{
    new STRING[64 + 1];
format( STRING, 64, \"%s\", VehicleNames[modell - 400][0] );
    return STRING;
}
« Utoljára szerkesztve: 2014. november 17. - 21:19:38 írta myke »

Jármű nevek
« Válasz #1 Dátum: 2014. november 18. - 15:24:30 »
0 Show voters
Ezt használd:
 
/*
Kocsi spawnoló
*/
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define l_red 0xFF0000AA
#define l_green 0x33FF33AA
public OnPlayerSpawn(playerid)
{
#if !defined IGNORE_SPAWN_MESSAGES
SendClientMessage( playerid, 0x00FF00AA, \"[KocsiSpawn]: Használat /kocsi\" );
#endif
return 1;
}
new aVehicleNames[212][] =
{
{\"Landstalker\"},
{\"Bravura\"},
{\"Buffalo\"},
{\"Linerunner\"},
{\"Perrenial\"},
{\"Sentinel\"},
{\"Dumper\"},
{\"Firetruck\"},
{\"Trashmaster\"},
{\"Stretch\"},
{\"Manana\"},
{\"Infernus\"},
{\"Voodoo\"},
{\"Pony\"},
{\"Mule\"},
{\"Cheetah\"},
{\"Ambulance\"},
{\"Leviathan\"},
{\"Moonbeam\"},
{\"Esperanto\"},
{\"Taxi\"},
{\"Washington\"},
{\"Bobcat\"},
{\"Mr Whoopee\"},
{\"BF Injection\"},
{\"Hunter\"},
{\"Premier\"},
{\"Enforcer\"},
{\"Securicar\"},
{\"Banshee\"},
{\"Predator\"},
{\"Bus\"},
{\"Rhino\"},
{\"Barracks\"},
{\"Hotknife\"},
{\"Trailer 1\"},
{\"Previon\"},
{\"Coach\"},
{\"Cabbie\"},
{\"Stallion\"},
{\"Rumpo\"},
{\"RC Bandit\"},
{\"Romero\"},
{\"Packer\"},
{\"Monster\"},
{\"Admiral\"},
{\"Squalo\"},
{\"Seasparrow\"},
{\"Pizzaboy\"},
{\"Tram\"},
{\"Trailer 2\"},
{\"Turismo\"},
{\"Speeder\"},
{\"Reefer\"},
{\"Tropic\"},
{\"Flatbed\"},
{\"Yankee\"},
{\"Caddy\"},
{\"Solair\"},
{\"Berkley\'s RC Van\"},
{\"Skimmer\"},
{\"PCJ-600\"},
{\"Faggio\"},
{\"Freeway\"},
{\"RC Baron\"},
{\"RC Raider\"},
{\"Glendale\"},
{\"Oceanic\"},
{\"Sanchez\"},
{\"Sparrow\"},
{\"Patriot\"},
{\"Quad\"},
{\"Coastguard\"},
{\"Dinghy\"},
{\"Hermes\"},
{\"Sabre\"},
{\"Rustler\"},
{\"ZR-350\"},
{\"Walton\"},
{\"Regina\"},
{\"Comet\"},
{\"BMX\"},
{\"Burrito\"},
{\"Camper\"},
{\"Marquis\"},
{\"Baggage\"},
{\"Dozer\"},
{\"Maverick\"},
{\"News Chopper\"},
{\"Rancher\"},
{\"FBI Rancher\"},
{\"Virgo\"},
{\"Greenwood\"},
{\"Jetmax\"},
{\"Hotring\"},
{\"Sandking\"},
{\"Blista Compact\"},
{\"Police Maverick\"},
{\"Boxville\"},
{\"Benson\"},
{\"Mesa\"},
{\"RC Goblin\"},
{\"Hotring Racer A\"},
{\"Hotring Racer B\"},
{\"Bloodring Banger\"},
{\"Rancher\"},
{\"Super GT\"},
{\"Elegant\"},
{\"Journey\"},
{\"Bike\"},
{\"Mountain Bike\"},
{\"Beagle\"},
{\"Cropdust\"},
{\"Stunt\"},
{\"Tanker\"},
{\"Roadtrain\"},
{\"Nebula\"},
{\"Majestic\"},
{\"Buccaneer\"},
{\"Shamal\"},
{\"Hydra\"},
{\"FCR-900\"},
{\"NRG-500\"},
{\"HPV1000\"},
{\"Cement Truck\"},
{\"Tow Truck\"},
{\"Fortune\"},
{\"Cadrona\"},
{\"FBI Truck\"},
{\"Willard\"},
{\"Forklift\"},
{\"Tractor\"},
{\"Combine\"},
{\"Feltzer\"},
{\"Remington\"},
{\"Slamvan\"},
{\"Blade\"},
{\"Freight\"},
{\"Streak\"},
{\"Vortex\"},
{\"Vincent\"},
{\"Bullet\"},
{\"Clover\"},
{\"Sadler\"},
{\"Firetruck LA\"},
{\"Hustler\"},
{\"Intruder\"},
{\"Primo\"},
{\"Cargobob\"},
{\"Tampa\"},
{\"Sunrise\"},
{\"Merit\"},
{\"Utility\"},
{\"Nevada\"},
{\"Yosemite\"},
{\"Windsor\"},
{\"Monster A\"},
{\"Monster B\"},
{\"Uranus\"},
{\"Jester\"},
{\"Sultan\"},
{\"Stratum\"},
{\"Elegy\"},
{\"Raindance\"},
{\"RC Tiger\"},
{\"Flash\"},
{\"Tahoma\"},
{\"Savanna\"},
{\"Bandito\"},
{\"Freight Flat\"},
{\"Streak Carriage\"},
{\"Kart\"},
{\"Mower\"},
{\"Duneride\"},
{\"Sweeper\"},
{\"Broadway\"},
{\"Tornado\"},
{\"AT-400\"},
{\"DFT-30\"},
{\"Huntley\"},
{\"Stafford\"},
{\"BF-400\"},
{\"Newsvan\"},
{\"Tug\"},
{\"Trailer 3\"},
{\"Emperor\"},
{\"Wayfarer\"},
{\"Euros\"},
{\"Hotdog\"},
{\"Club\"},
{\"Freight Carriage\"},
{\"Trailer 3\"},
{\"Andromada\"},
{\"Dodo\"},
{\"RC Cam\"},
{\"Launch\"},
{\"Police Car (LSPD)\"},
{\"Police Car (SFPD)\"},
{\"Police Car (LVPD)\"},
{\"Police Ranger\"},
{\"Picador\"},
{\"S.W.A.T. Van\"},
{\"Alpha\"},
{\"Phoenix\"},
{\"Glendale\"},
{\"Sadler\"},
{\"Luggage Trailer A\"},
{\"Luggage Trailer B\"},
{\"Stair Trailer\"},
{\"Boxville\"},
{\"Farm Plow\"},
{\"Utility Trailer\"}
};
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[200], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, \"/kocsi\", true, 10) == 0)
{
new String[200];
new tmp[256];
new Float:x, Float:y, Float:z;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, l_red, \"Nem adtál meg kocsi nevet\");
new vehicle = GetVehicleModelIDFromName(tmp);
if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, l_red, \"A kocsi neve nem létezik\");
new Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
   GetXYInFrontOfPlayer(playerid, x, y, 8);
}
else
{
    GetXYInFrontOfPlayer(playerid, x, y, 5);
}
new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
format(String, sizeof(String), \"Lespawnoltál egy járművet %s\", aVehicleNames[vehicle - 400]);
SendClientMessage(playerid, l_green, String);
return 1;
}
return 0;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= \' \'))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > \' \') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
GetVehicleModelIDFromName(vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(aVehicleNames, vname, true) != -1)
return i + 400;
}
return -1;
}
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x2, y2, a);
GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x2 += (distance * floatsin(-a, degrees));
y2 += (distance * floatcos(-a, degrees));
}
« Utoljára szerkesztve: 2014. november 18. - 15:34:05 írta Chrispapa »

Nem elérhető myke

  • 213
    • Profil megtekintése
Jármű nevek
« Válasz #2 Dátum: 2014. november 18. - 16:50:49 »
0 Show voters
Okés, köszi, valamit kihozok belőle.
« Utoljára szerkesztve: 2014. november 18. - 16:52:22 írta myke »

Jármű nevek
« Válasz #3 Dátum: 2014. november 18. - 17:32:13 »
0 Show voters
Hát igazán nincs mit. ;D

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal