Money issue.
#1

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?
Reply
#2

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
Reply
#3

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.
Reply
#4

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 )
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)