error 035: argument type mismatch (argument 1)
#1

So these are the errors, I get.
PHP код:
C:\Users\ъеош\Desktop\Server\gamemodes\Test.pwn(228) : error 035argument type mismatch (argument 1)
C:\Users\ъеош\Desktop\Server\gamemodes\Test.pwn(230) : error 035argument type mismatch (argument 1)
C:\Users\ъеош\Desktop\Server\gamemodes\Test.pwn(232) : error 035argument type mismatch (argument 1)
C:\Users\ъеош\Desktop\Server\gamemodes\Test.pwn(235) : error 035argument type mismatch (argument 1
I typed "// Error" at the end of the lines that cause the errors.
PHP код:
CMD:slap(playeridparams[])
{
    new 
id[50];
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_RED"[Error] You are not authorised to use this command!");
    else if(
sscanf(params"u"id)) return SendClientMessage(playeridCOLOR_WHITE"[Usage] /slap [User ID]");
    else
    {
        new 
Float:x,
            
Float:y,
            
Float:z,
            
name[MAX_PLAYER_NAME+1],
            
name2[MAX_PLAYER_NAME+1],
            
message[84];
        
GetPlayerPos(idxyz); // Error one.
        
GetPlayerName(playeridnamesizeof(name));
        
GetPlayerName(idname2sizeof(name2)); // Error two.
        
format(messagesizeof(message), "[Info] You were slapped by the administrator %s."name);
        
SendClientMessage(idCOLOR_WHITEmessage); // Error three.
        
format(messagesizeof(message), "[SUCCESS] You just slapped %s."name2);
        
SendClientMessage(playeridCOLOR_WHITEmessage);
        
SetPlayerPos(idxy5); // Error four.
    
}
    return 
1;

Reply
#2

Replace "id" with "playerid"
Reply
#3

Why would I do that?
I am not trying to get the position of the one who's typing the command, neither am I trying to get his name etc..
I want the position etc.. of the ID I type in.
Which is why I don't understand the errors.
Reply
#4

You should use:
pawn Код:
new id;
Not:
pawn Код:
new id[50];
Reply
#5

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
You should use:
pawn Код:
new id;
Not:
pawn Код:
new id[50];
Thanks it now perfectly works
Would you mind explaining me how though? I am just curious why I can't do [] with an ID.
Reply
#6

ID is only a number, not a string. Further info here.
Reply
#7

Quote:
Originally Posted by Tomer!.$
Посмотреть сообщение
Thanks it now perfectly works
Would you mind explaining me how though? I am just curious why I can't do [] with an ID.
[] are used to store multiple data in a single identifier.They are known as arrays.

new i; will create a variable.

new i[5] will create 5 variables but with the same identifier.It is accessed by i[0] for the 1st element.

In your code if you declare id[50] and pass it on as a parameter, the compiler would end up not knowing what to do since it requires just one variable(and you are giving 50;obviously, what could it do).

The ultimate change required is give just one variable instead of multiple and it can be solved by new id; or by giving just one variable by i[1].

If you have never heard of arrays or did not understand what I told, visit THIS and start learning the PAWN language.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)