Help Command +rep
#1

i so frustation
sir, can you edit this command to ZCMD?? please
if work, +rep :v

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new
      cmd[128],
      tmp[32],
      tmp2[256], tmp3[256], tmp4[256],idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/car", true)==0)
    {

            //if(IsPlayerInAnyVehicle(playerid)) { return SendClientMessage(playerid, COLOUR_ORANGE, "You arleday have a car"); }

            tmp = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext,idx);
            tmp3 = strtok(cmdtext,idx);
            tmp4 = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 32) { return SendClientMessage(playerid, COLOUR_ORANGE, "System: /car [name/id] [color1] [color2]"); }

            new
              car,colour1, colour2;

            if(!IsNumeric(tmp)) { car = GetVehicleModelIDFromName(tmp); } else { car = strval(tmp); }
            if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
            if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
            if(car > 611 || car < 400) { return SendClientMessage(playerid, COLOUR_ORANGE, "Wrong car name or id"); }

            if(CreateCar[playerid] != -1) { DestroyVehicle(CreateCar[playerid]); }

            new
                Float:pos[4];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            GetPlayerFacingAngle(playerid, pos[3]);

            CreateCar[playerid] = CreateVehicle(car, pos[0], pos[1], pos[2], pos[3],colour1,colour2, 50000);
            SetVehicleNumberPlate(CreateCar[playerid], tmp4);
            SetVehicleToRespawn(CreateCar[playerid]);
            PutPlayerInVehicle(playerid, CreateCar[playerid], 0);
            SetVehicleVirtualWorld(CreateCar[playerid], GetPlayerVirtualWorld(playerid));

            new
              MaxPlayers = GetMaxPlayers();
            for(new i; i < MaxPlayers; i++)
            {
              if(!IsPlayerConnected(i) || i == playerid) continue;

              SetVehicleParamsForPlayer(CreateCar[playerid], i, 0, true);
            }

            //new
              //string[144];
            //format(string, sizeof string, " %s SPAWNED SUCCESFUL", VehicleNames[car-400]);
            //SendClientMessage(playerid, COLOUR_BLUE, string);

            return 1;
    }
    return 0;
}
Reply
#2

http://pastebin.com/DPPg3xME

You'll need sscanf and foreach (everyone should use these).

I changed a few things also. You need to change your use of CreateCar[]. No need to set it to -1 when it's invalid, just leave it initialised to 0 (vehicle IDs start at 1).

Also, you should really use 'COLOR' not 'COLOR', as it keeps things consistent (because the SA-MP functions are color).

Note that in your code you never give an option for a vehicle name to be entered - just an ID - although it appears you want the name. I made it ID only.

I also commented out the numberplate line as there's no parameter to pass to it. Not sure what it was doing before..

I also commented out the respawn function, as it makes no sense to create a vehicle then instantly respawn it.

Also, check the respawn time in your vehicle creation function. It's SECONDS, not milliseconds.
Reply
#3

than, how to disable spawn car with id?

exlampe

car elegy

if type

car 562

uknow command/ not have command on this server
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)