problem with tuning command
#1

Hi.

I wanted to create a command on which my car gets tuned. There should be different tuning styles to select by parameter.
This works quite well, BUT the first tuning style is also applied if you just enter the command without parameter.

this is my command
pawn Код:
dcmd_nitro(playerid, params[])      //tuning
{
    if(sscanf(params, "s"))
        {
            SendClientMessage(playerid, 0xFF0000FF, "Usage: /nitro <type>");
        }
    else if(IsPlayerInAnyVehicle(playerid) == 1)
    {
        if(!strcmp(params, "gold", true))   //yellow/black,switch rims
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
            AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
            AddVehicleComponent(GetPlayerVehicleID(playerid),1080);
            ChangeVehicleColor(GetPlayerVehicleID(playerid),6,0);
            PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
        }
        else if(!strcmp(params, "pink", true))  //pink/blue,offroad wheels
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
            AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
            AddVehicleComponent(GetPlayerVehicleID(playerid),1025);
            ChangeVehicleColor(GetPlayerVehicleID(playerid),126,2);
            PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
        }
        else{SendClientMessage(playerid, 0xFF0000FF, "SERVER: Please use a valid tuning style.");}
    }
    else {SendClientMessage(playerid, 0xFF0000FF, "SERVER: No car no nitro ;-)");}
    return 1;
}
If anybody could tell me what i missed out here.... would be great

thanks in advance
Reply
#2

Something like this?

pawn Код:
dcmd_nitro(playerid, params[])      //tuning
{
    new type[10];
    if(sscanf(params, "s[10]",type)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /nitro <type>");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "SERVER: No car no nitro ;-)");
    if(strcmp(type,"gold",true) == 0)
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
        AddVehicleComponent(GetPlayerVehicleID(playerid),1080);
        ChangeVehicleColor(GetPlayerVehicleID(playerid),6,0);
        PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
        SendClientMessage(playerid,0xFF0000FF, "Gold nitro activated!");
    }
    else if(strcmp(type,"pink",true) == 0)
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
        AddVehicleComponent(GetPlayerVehicleID(playerid),1025);
        ChangeVehicleColor(GetPlayerVehicleID(playerid),126,2);
        PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
        SendClientMessage(playerid,0xFF0000FF, "Pink nitro activated!");
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000FF, "SERVER: Please use a valid tuning style.");
    }
    return 1;
}
Reply
#3

Thx for the quick help. Works fine now
Reply
#4

You welcome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)