Set a variable to what they ask
#10

Try this :
pawn Код:
// Top of the ' OnPlayerCommandText ' callback.

new cmd[128], idx;
cmd = strtok(cmdtext, idx);

// Under ' OnPlayerCommandText ' callback.

if(strcmp(cmd, "/changestation", true) == 0)
{
    new station, tmp[128];
    tmp = strtok(cmdtext, idx);
    station = strval(tmp);
    if(IsPlayerInAnyVehicle(playerid));
    {
        if(strlen(station))
        {
            if(IsNumeric(station))
            {
                if(station > 0 || station < 6) // Example: This makes you can choose between 1 - 5.
                {
                    if(station == 1)
                    {
                        RadioChannel[vehicleid] = 1;
                        SendClientMessage(vehicleid, COLOR_ORANGE, "Radio station set to number one.");
                        return 1;
                    }
                    else if(station == 2)
                    {
                        RadioChannel[vehicleid] = 2;
                        SendClientMessage(vehicleid, COLOR_ORANGE, "Radio station set to number two.");
                        return 1;
                    }
                    else if(station == 3)
                    {
                        RadioChannel[vehicleid] = 3;
                        SendClientMessage(vehicleid, COLOR_ORANGE, "Radio station set to number three.");
                        return 1;
                    }
                    else if(station == 4)
                    {
                        RadioChannel[vehicleid] = 4;
                        SendClientMessage(vehicleid, COLOR_ORANGE, "Radio station set to number four.");
                        return 1;
                    }
                    else if(station == 5)
                    {
                        RadioChannel[vehicleid] = 5;
                        SendClientMessage(vehicleid, COLOR_ORANGE, "Radio station set to number five.");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_ORANGE, "Choose a station number from 1 to 5.");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_ORANGE, "Invalid station number.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_ORANGE, "Type: /changestation [1 - 5]");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE, "You're not even in a vehicle.");
    }
}
Reply


Messages In This Thread
Set a variable to what they ask - by Zack9764 - 19.02.2011, 14:38
Re: Set a variable to what they ask - by Serbish - 19.02.2011, 14:44
AW: Set a variable to what they ask - by !Phoenix! - 19.02.2011, 14:48
Re: Set a variable to what they ask - by Zack9764 - 19.02.2011, 15:22
Re: Set a variable to what they ask - by Serbish - 19.02.2011, 15:37
Re: Set a variable to what they ask - by Zack9764 - 19.02.2011, 15:45
Re: Set a variable to what they ask - by Mean - 19.02.2011, 15:49
Re: Set a variable to what they ask - by Serbish - 19.02.2011, 15:50
Re: Set a variable to what they ask - by Zack9764 - 19.02.2011, 16:21
Re: Set a variable to what they ask - by maramizo - 19.02.2011, 16:30

Forum Jump:


Users browsing this thread: 2 Guest(s)