[Help]/SetPlate command isn't working the way I want it to
#1

This is the script I made for it. It works fine, but when the car spawns, the only thing you see on it is the first letter of the plate you put.
This is the command:

PHP код:
command(setplateplayeridparams[])
{
    new 
platevehslot;
    if(
sscanf(params"ci"platevehslot))
    {
        
SendClientMessage(playeridWHITE"SYNTAX: /setplate [Plate] [Car Slot]");
    }
    else
    {
        switch(
vehslot)
        {
            case 
1:
            {
                
Player[playerid][CarPlate] = plate;
            }
            case 
2:
            {
                
Player[playerid][CarPlate2] = plate;
            }
            case 
3:
            {
                
Player[playerid][CarPlate3] = plate;
            }
            case 
4:
            {
                
Player[playerid][CarPlate4] = plate;
            }
            case 
5:
            {
                
Player[playerid][CarPlate5] = plate;
            }
        }
    }
    return 
1;

When it spawns the car, this is what its running:

PHP код:
SetVehicleNumberPlate(Player[playerid][CarLinkID], Player[playerid][CarPlate]); 
It is using that for each car spawn. Thanks!
Reply
#2

I could be wrong, and this is NOT tested.
pawn Код:
// You're using a out-dated method of ZCMD...for starters.
CMD:setplate(playerid,params[])
{
    new plate[8], vehslot;// Max numbers is 8(I believe.)
    if(sscanf(params, "s[8]i", plate, vehslot))
    {
        SendClientMessage(playerid, WHITE, "SYNTAX: /setplate [Plate] [Car Slot]");
    }
    else
    {
        new car = GetPlayerVehicleID(playerid);// Might need new car = GetPlayerVehicleID(playerid) - 1;
        new Float:cX, Float:cY, Float:cZ, Float:A;
        switch(vehslot)
        {
            case 0:// Starts at Case 0:, not Case 1:
            {
                Player[playerid][CarPlate] = plate;
                SetVehicleToRespawn(car);
                SetVehiclePos(car, cX, cY, cZ);
                PutPlayerInVehicle(playerid,vehicleid,0);
            }
            case 1:
            {
                Player[playerid][CarPlate2] = plate;
                SetVehicleToRespawn(car);
                SetVehiclePos(car, cX, cY, cZ);
                PutPlayerInVehicle(playerid,vehicleid,0);
            }
            case 2:
            {
                Player[playerid][CarPlate3] = plate;
                SetVehicleToRespawn(car);
                SetVehiclePos(car, cX, cY, cZ);
                PutPlayerInVehicle(playerid,vehicleid,0);
            }
            case 3:
            {
                Player[playerid][CarPlate4] = plate;
                SetVehicleToRespawn(car);
                SetVehiclePos(car, cX, cY, cZ);
                PutPlayerInVehicle(playerid,vehicleid,0);
            }
            case 4:
            {
                Player[playerid][CarPlate5] = plate;
                SetVehicleToRespawn(car);
                SetVehiclePos(car, cX, cY, cZ);
                PutPlayerInVehicle(playerid,vehicleid,0);
            }
        }
    }
    return 1;
}
Reply
#3

Lynn, there are several flaws with your code...

He's not using an out-dated version of ZCMD, it's just a different syntax for ZCMD. You can use any of the following; command( - COMMAND: - CMD:

Vehicle plates can be 32 characters long (but keep in mind not all of them are visible on all (if any) vehicles).

And I'm not sure about the code below. The player's vehicle ID is the one which is returned by GetPlayerVehicleID... there's no reason to subtract one (1) from the returned ID.

pawn Код:
new car = GetPlayerVehicleID(playerid);// Might need new car = GetPlayerVehicleID(playerid) - 1;
Also, to actually set the plate, you need to have a spawned vehicle already. Then you can call SetVehicleNumberPlate, but then you also need to re-spawn the vehicle of which you set the number plate.

Sources:

https://sampforum.blast.hk/showthread.php?tid=91354

https://sampwiki.blast.hk/wiki/SetVehicleNumberPlate

https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)