SA-MP Forums Archive
ZCMD + SSCANF PROBLEM - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ZCMD + SSCANF PROBLEM (/showthread.php?tid=109721)



ZCMD + SSCANF PROBLEM - Zeromanster - 21.11.2009

I'm trying to create /give [ID/PartOfName] [item] [amount] but im not succeding.

Here's my code:

pawn Код:
cmd(give, playerid, params[])
{
  if(IsPlayerConnected(playerid) && PlayerLoggedIn[playerid])
  {
    new player[32];
    new item[128];
    new amount[32];
    sscanf(params, "uss", player, item, amount);
    if(isnull(player))
    {
      SendClientMessage(playerid, COLOR_HELP, "USAGE: /give [ID/PartOfName] [item] [amount]");
      SendClientMessage(playerid, COLOR_HELP, "ITEMS: money, gun");
      return 1;
    }
    if(isnull(item))
    {
      SendClientMessage(playerid, COLOR_HELP, "USAGE: /give [ID/PartOfName] [item] [amount]");
      SendClientMessage(playerid, COLOR_HELP, "ITEMS: money, gun");
      return 1;
    }
    if(!strcmp(item, "money"))
    {
      if(isnull(amount))
      {
         SendClientMessage(playerid, COLOR_HELP, "USAGE: /give [ID/PartOfName] [item] [amount]");
         SendClientMessage(playerid, COLOR_HELP, "ITEM: money, gun");
         return 1;
      }
      GivePlayerCash(playerid,-amount); // Line: 3285
      GivePlayerCash(player,amount); // Line: 3286
    }
  }    
  return 1;
}
I didn't even finish the command and i get this errors:

Код:
C:\Documents and Settings\Ivan\Desktop\SERVER\gamemodes\cgrpg.pwn(3285) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Ivan\Desktop\SERVER\gamemodes\cgrpg.pwn(3286) : error 035: argument type mismatch (argument 1)
Please help me fix it. Thank you.


Re: ZCMD + SSCANF PROBLEM - Donny_k - 21.11.2009

This has nothing to do with zcmd or sscanf it's you trying to check the index of a none array (player).

pawn Код:
if ( isnull(player //player isn't a string, a string is an array of characters
Edit:

Learn from my reply, you are doing the same thing but the other way around now.


Re: ZCMD + SSCANF PROBLEM - Zeromanster - 21.11.2009

Quote:
Originally Posted by Donny
This has nothing to do with zcmd or sscanf it's you trying to check the index of a none array (player).

pawn Код:
if ( isnull(player //player isn't a string, a string is an array of characters
I've replaced

pawn Код:
new player;
with

pawn Код:
new player[32];
and that error has been fixed, but new ones appeared and i can't fix them.

I updated my first post. Please help, thanks...


Re: ZCMD + SSCANF PROBLEM - Donny_k - 21.11.2009

Quote:
Originally Posted by Donny
This has nothing to do with zcmd or sscanf it's you trying to check the index of a none array (player).

pawn Код:
if ( isnull(player //player isn't a string, a string is an array of characters
Edit:

Learn from my reply, you are doing the same thing but the other way around now.



Re: ZCMD + SSCANF PROBLEM - dre$tA - 21.11.2009

Try this:
Код:
cmd(give, playerid, params[])
{
  if(PlayerLoggedIn[playerid] != 1) return 1;
	new player;
	new item[12];
	new amount;
	if(sscanf(params, "usd", player, item, amount))
	{
	  SendClientMessage(playerid, COLOR_HELP, "USAGE: /give [ID/PartOfName] [item] [amount]");
	  SendClientMessage(playerid, COLOR_HELP, "ITEMS: money, gun");
	  return 1;
	}
	else if(player == INVALID_PLAYER_ID)
	{
	  SendClientMessage(playerid, COLOR_HELP, "Player not found.");
	  return 1;
	}
	if(!strcmp(item, "money", true))
	{
		GivePlayerCash(playerid, -amount);
		GivePlayerCash(player, amount);
	}
 	return 1;
}



Re: ZCMD + SSCANF PROBLEM - Zeromanster - 22.11.2009

Thanks dre$tA. It works great.