Help please
#1

im trying to make a command

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
if (strcmp("/asslick", cmdtext, true))
{
new tmp[30];
tmp = strtok(cmdtext, idx);
new otherplayer = strval(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Usage: /asslick [id]");
if(IsPlayerConnected(otherplayer))
{
SendClientMessage(playerid, #F781F3," You're now Asslicking %d ! Have a good time doing it! also heres $1 for you " );
SendClientMessageToAll(#F781F3, "%s is now asslicking %d ! He should be proud of himself!" );
SendClientMessage(otherplayer, 0xE21D2CFF, "%d is now asslicking you! he be good friend! " );
GivePlayerMoney(playerid, 1);
}
else
{
SendClientMessage(#F781F3, "Haha!, The Player you are trying to asslick isn't online! noob.");
}
return 1;
}
return 0;
}

then get these errors

Quote:

C:\Documents and Settings\gamer\Desktop\MW-DM\filterscripts\asslick.pwn(16) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\gamer\Desktop\MW-DM\filterscripts\asslick.pwn(17) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\gamer\Desktop\MW-DM\filterscripts\asslick.pwn(23) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

what do i do? please help
Reply
#2

  • Your strcmp check is wrong, strcmp returns 0 when a match was found, so you need to check if its return is equal to 0.
  • You're using strtok wrong in this example as well. Strtok tokenizes a string, and returns a token based on the current index. In the example you are getting the command itself, instead of the parameters. To fix this use strtok in the OnPlayerCommandText callback to get the command first, use strcmp to compare the token to make sure its the right command, and then use strtok again to get the parameters (all while using the same index, its passed by reference and will increment itself so you get the next token).
  • You're using a bad method to check if a string is null, you should use isnull by ******.
  • Your SendClientMessages are completely messed up (this is where the errors come from). In pawn, hex is represented by the constant "0x" so if you want a white color, you dont use #FFFFFFFF, you use 0xFFFFFFFF. The operator "#" is known as the stringize operator and turns the preceding hex color into a string, and thats why you're getting a type mismatch.
  • Another problem with you're SendClientMessage(ToAll) is that you're trying to use format specifiers, which doesnt work, for that you have to use the function format. Information can be found here
  • Indent your code so its easier to read and understand.

Also i'd look into sscanf and zcmd, its a LOT simpler and does a hell of a lot more in terms of functionality.
Reply
#3

Thanks
Reply
#4

Quote:
Originally Posted by darkknight123
Посмотреть сообщение
Thanks
No problem, if you need more help with this shoot me a pm .


Though i really do suggest looking into sscanf and zcmd. Better speed, easier to use, and they do more .
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)