Set a variable to what they ask
#1

Код:
           new station = strcmp(cmdtext);
	   if(RadioStatus[vehicleid] == 1)
	   {
		if(strcmp(station,"1",true) == 0)
		{
	      	        RadioChannel[vehicleid] = 1;
	      		SendClientMessage(vehicleid, COLOR_ORANGE,"Radio station set to number one");
	      		return 1;
      		}
           }
What am I doing wrong? I'm confused on how to do this.

Код:
error 035: argument type mismatch (argument 1)
Reply
#2

So, you want it happens if you type in chat " 1 " ?
Reply
#3

Which line?
SendClientMessage I assume? (Only possible line here)

But why do you send a message to a vehicle?


//------------
Edit:
Check https://sampwiki.blast.hk/wiki/Strcmp
(Please always flag the line where the error occurs)
Reply
#4

Quote:
Originally Posted by Serbish
Посмотреть сообщение
So, you want it happens if you type in chat " 1 " ?
/Changestation 1

Код:
if(strcmp(cmd, "/changestation", true) == 0)
Is above it.

Quote:
Originally Posted by !Phoenix!
But why do you send a message to a vehicle?
Don't worry about it.

I'm getting the error on the strcmp line.
Reply
#5

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

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

// Under ' OnPlayerCommandText ' callback.

if(strcmp(cmd, "/changestation", true) == 0)
{
    new station;
    tmp = strtok(cmdtext, idx);
    station = strval(tmp);
    if(strlen(tmp))
    {
        if(IsNumeric(tmp))
        {
            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;
    }
}
Reply
#6

Quote:
Originally Posted by Serbish
Посмотреть сообщение
pawn Код:
// Top of the ' OnPlayerCommandText ' callback.

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

// Under ' OnPlayerCommandText ' callback.

if(strcmp(cmd, "/changestation", true) == 0)
{
    new station;
    tmp = strtok(cmdtext, idx);
    station = strval(tmp);
    if(strlen(tmp))
    {
        if(IsNumeric(tmp))
        {
            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;
    }
}
Can you also cure cancer for me?
Reply
#7

Quote:
Originally Posted by Zack9764
Посмотреть сообщение
Can you also cure cancer for me?
Indirect point? He was just offering you help. What the hell do you want else.
Reply
#8

EDIT: I didn't understand it.
Reply
#9

No, when you type the CMD it does nothing.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)