SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 21/11/2009, 11:24 PM   #1
Zeromanster
Huge Clucker
 
Join Date: Oct 2008
Posts: 419
Reputation: 3
Default ZCMD + SSCANF PROBLEM

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

Here's my code:

pawn Code:
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:

Code:
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.
Zeromanster is offline  
Old 21/11/2009, 11:31 PM   #2
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 786
Reputation: 4
Default Re: ZCMD + SSCANF PROBLEM

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

pawn Code:
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.
__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline  
Old 21/11/2009, 11:38 PM   #3
Zeromanster
Huge Clucker
 
Join Date: Oct 2008
Posts: 419
Reputation: 3
Default Re: ZCMD + SSCANF PROBLEM

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 Code:
if ( isnull(player //player isn't a string, a string is an array of characters
I've replaced

pawn Code:
new player;
with

pawn Code:
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...
Zeromanster is offline  
Old 21/11/2009, 11:42 PM   #4
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 786
Reputation: 4
Default Re: ZCMD + SSCANF PROBLEM

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 Code:
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.
__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline  
Old 21/11/2009, 11:50 PM   #5
dre$tA
Big Clucker
 
Join Date: Feb 2008
Posts: 61
Reputation: 0
Default Re: ZCMD + SSCANF PROBLEM

Try this:
Code:
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;
}
dre$tA is offline  
Old 22/11/2009, 12:03 AM   #6
Zeromanster
Huge Clucker
 
Join Date: Oct 2008
Posts: 419
Reputation: 3
Default Re: ZCMD + SSCANF PROBLEM

Thanks dre$tA. It works great.
Zeromanster is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
zcmd problem QuaTTrO Help Archive 2 16/05/2011 05:45 PM
ZCMD/SSCANF PROBLEM Zeromanster Help Archive 2 27/02/2010 11:26 PM
sscanf and zcmd question about commands with multi parameters Dujma Help Archive 3 21/11/2009 01:24 AM
[Help]Zcmd & sscanf Dirty_bum Help Archive 2 28/10/2009 12:10 PM


All times are GMT. The time now is 12:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.