Question regarding zcmd and sscanf.
#1

So I'm attempting to make a command, that will change a player's paint job in a vehicle. The command is only for VIP's. I want it so the player needs to do /vpaint 1-3. in order to change his current paint job. How would I make it so if he did /vpaint 1, it would change the paint job to 1. Same with /vpaint 2 and 3.

Thank you.

pawn Код:
CMD:vpaint(playerid, params[])
{
    if(PlayerInfo[playerid][pVip] >=1 )
    {
        new paintjob;
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED, "ERROR: You're not in a vehicle.");
        if(sscanf(params, "i",paintjob)) return SendClientMessage(playerid,COLOR_WHITE, "USAGE: /vpaint [1-3]");

    }
    else return SendClientMessage(playerid,COLOR_GREY, ERROR);
    return 1;
}
Reply
#2

PHP код:
CMD:vpaint(playeridparams[])
{
    if(
PlayerInfo[playerid][pVip] >=)
    {
        new 
paintjob;
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED"ERROR: You're not in a vehicle.");
        if(
sscanf(params"i",paintjob)) return SendClientMessage(playerid,COLOR_WHITE"USAGE: /vpaint [1-3]");
        if(
paintjob == 1)
        {
            
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
        }
        else if(
paintjob == 2)
        {
            
ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
        }
    }
    else return 
SendClientMessage(playerid,COLOR_GREYERROR);
    return 
1;

Make sure you change the variables "color[0]" & "color[1]" to what you want.
Reply
#3

I was wondering if that was what I needed to do, lol. Thanks for the help buddy.
Reply
#4

pawn Код:
CMD:vpaint(playerid, params[])
{
    if(PlayerInfo[playerid][pVip] >=1 )
    {
        new paintjob;
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED, "ERROR: You're not in a vehicle.");
        if(sscanf(params, "i",paintjob)) return SendClientMessage(playerid,COLOR_WHITE, "USAGE: /vpaint [1-3]");
        ChangeVehiclePaintjob(GetPlayerVehicleID(playerid), paintjob);
    }
    else return SendClientMessage(playerid,COLOR_GREY, ERROR);
    return 1;
}
Something like this, not tested.
Reply
#5

Got it to meet my personal standards, thanks for the help everyone.
Reply
#6

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
Got it to meet my personal standards, thanks for the help everyone.
Just know that I only added the ChangeVehiclePaintjob line from the original code you posted.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)