License plate changing command.
#1

Here is the command. You do /licenseplate [Text]
pawn Код:
if(strcmp(cmd, "/licenseplate", true) == 0)
    {
    if(PlayerInfo[playerid][Level] >= 1)
    {
        if (GetPlayerState(playerid) == 2)
        {
            new VehicleID = GetPlayerVehicleID(playerid), LModel = GetVehicleModel(VehicleID);
            switch(LModel)
            {
                case 448,461,462,463,468,471,509,510,521,522,523,581,586, 449: return SendClientMessage(playerid,red,"ERROR: You can not tune this vehicle");
            }
            new str[128], Float:pos[3]; format(str, sizeof(str), "%s", cmdtext[2]);
            SetVehicleNumberPlate(VehicleID, str);
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]); SetPlayerPos(playerid, pos[0]+1, pos[1], pos[2]);
            SetVehicleToRespawn(VehicleID); SetVehiclePos(VehicleID, pos[0], pos[1], pos[2]);
            SetTimerEx("TuneLCar",4000,0,"d",VehicleID);    PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
            SendClientMessage(playerid, blue, "You have changed your licence plate");
            }
            else
            {
                SendClientMessage(playerid,red,"Error: You have to be the driver of a vehicle to change its licence plate");
            }
        }
        else
        {
            SendClientMessage(playerid,red,"ERROR: You need to be level 1 use this command");
        }
    return 1;
    }
Everything compiles fine but this is what it looks like In game.
Reply
#2

pawn Код:
format(str, sizeof(str), "%s", cmdtext[2]);
            SetVehicleNumberPlate(VehicleID, str);
This code will set numberplate to 3rd character on cmdtext. Which is i
Use sscanf to put number plate of player's choice
Reply
#3

What is the problem in it?
Reply
#4

Use this
pawn Код:
CMD:licenseplate(playerid,params[])
{
    if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,red,"ERROR: You need to be level 1 use this command");
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid,-1,"Error: You have to be the driver of a vehicle to change its licence plate");
    new VehicleID = GetPlayerVehicleID(playerid), LModel = GetVehicleModel(VehicleID);
    switch(LModel)
    {
        case 448,461,462,463,468,471,509,510,521,522,523,581,586, 449: return SendClientMessage(playerid,-1,"ERROR: You can not tune this vehicle");
    }
    new plate[32];
    if(sscanf(params,"s[32]",plate)) return SendClientMessage(playerid,-1,"Correct Usage : /licenseplate [PLATE] ");
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    SetVehicleNumberPlate(VehicleID, plate);
    SetVehicleToRespawn(VehicleID);
    SetVehiclePos(VehicleID, pos[0], pos[1], pos[2]);
    SetTimerEx("TuneLCar",4000,0,"d",VehicleID);
    PutPlayerInVehicle(playerid,VehicleID,0);
    PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
Use this
pawn Код:
CMD:licenseplate(playerid,params[])
{
    if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,red,"ERROR: You need to be level 1 use this command");
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid,-1,"Error: You have to be the driver of a vehicle to change its licence plate");
    new VehicleID = GetPlayerVehicleID(playerid), LModel = GetVehicleModel(VehicleID);
    switch(LModel)
    {
        case 448,461,462,463,468,471,509,510,521,522,523,581,586, 449: return SendClientMessage(playerid,-1,"ERROR: You can not tune this vehicle");
    }
    new plate[32];
    if(sscanf(params,"s[32]",plate)) return SendClientMessage(playerid,-1,"Correct Usage : /licenseplate [PLATE] ");
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    SetVehicleNumberPlate(VehicleID, plate);
    SetVehicleToRespawn(VehicleID);
    SetVehiclePos(VehicleID, pos[0], pos[1], pos[2]);
    SetTimerEx("TuneLCar",4000,0,"d",VehicleID);
    PutPlayerInVehicle(playerid,VehicleID,0);
    PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
    return 1;
}
You'll need sscanf from ******. You can get it here https://sampforum.blast.hk/showthread.php?tid=120356
You'll need ZCMD from Zeex. You can get it here https://sampforum.blast.hk/showthread.php?tid=91354
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)