SA-MP Forums Archive
Money issue. - 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)
+--- Thread: Money issue. (/showthread.php?tid=499059)



Money issue. - Djsoulhart - 06.03.2014

I'm a new scripter when it comes to pawno..and various other things.. So as a test I wanted to make my own TDM server though I mainly use it for mapping.

I added a command that allows you to buy weapons but I couldn't figure out how to make it say if you didn't have enough cash you couldn't buy it. I tried two separate things bug got the same error



PHP код:

        
        
if(GetPlayerMoney(playerid) >= 500)
        {
        if(
strcmp("/shotgun"cmdtexttrue10) == 0
            
{
            
GivePlayerMoney(playerid, -500);
            
GivePlayerWeapon(playerid25100);
            
SendClientMessage(playeridCOLOR_RED"You have just bought a shotgun!");
            }
          else
              {
              
SendClientMessage(playeridCOLOR_RED"You do not have enough funds for this weapon!");
              return 
1;
              }
        }
          
        
/* The code on top I get the error "Invalid expression, assumed zero */
        
        
        
if (strcmp("/shotgun"cmdtexttrue10) == GetPlayerMoney(playerid) >=0)
        {
            
GivePlayerMoney(playerid, -500);
            
GivePlayerWeapon(playerid25100);
            
SendClientMessage(playeridCOLOR_RED"You have just bought a shotgun!");
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"You do not have enough funds for this weapon!");
            return 
1;
        }
        
               
/* For this one I get "Tag mismatch" */ 
Any idea's on what I am doing wrong?


Re: Money issue. - Pillhead2007 - 06.03.2014

PHP код:
if(strcmp("/shotgun"cmdtexttrue10) == 0)

  if(
GetPlayerMoney(playerid) >= 500)
  {
    
GivePlayerMoney(playerid, -500);
  }
  else if(
GetPlayerMoney(playerid, < 500)
  {
    
sendclientmessage(playerid,COLOR_WHITE,"you don't have Enough cash!");
  }
}
return 
1



Re: Money issue. - Misiur - 06.03.2014

pawn Код:
//First snippet
if(strcmp("/shotgun", cmdtext, true, 10) == 0 //<-- missing closing ")"
Second snippet is totally wrong, as it will return "not enough funds" for every command which isn't /shotgun, and is overall messy.


Re: Money issue. - XK - 06.03.2014

Make it:
pawn Код:
if(GetPlayerMoney(playerid) >= 500)
{
    GivePlayerMoney(playerid, -500);
}
else if(GetPlayerMoney(playerid, < 500)
{
    SendClientMessage(playerid,-1,"you don't have Enough cash to buy this weapon!");
}
and as Misiur said,you are missing to close it,put )


Re: Money issue. - Djsoulhart - 06.03.2014

Quote:
Originally Posted by XK
Посмотреть сообщение
Make it:
pawn Код:
if(GetPlayerMoney(playerid) >= 500)
{
    GivePlayerMoney(playerid, -500);
}
else if(GetPlayerMoney(playerid, < 500)
{
    SendClientMessage(playerid,-1,"you don't have Enough cash to buy this weapon!");
}
and as Misiur said,you are missing to close it,put )
Now that confuses me, I want to make this a command for the shotgun.. but make it so if the player doesn't have enough cash I want it to deny it to them.

NVM, I figured it out; thank you <3