SA-MP Forums Archive
What is wrong with this ? - 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: What is wrong with this ? (/showthread.php?tid=582073)



What is wrong with this ? - IndependentGaming - 17.07.2015

Hello, i try to fix this problem if you dont have 500$ it say you dont have the cash for this item, and you need to be gold vip + to buy a gun.

Error:
PHP код:
 error 029invalid expressionassumed zero
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

PHP код:
if(listitem == 0)
        {
            if (
GetPlayerCash(playerid) >= 500 && PlayerInfo[playerid][pDonateRank] >= 3)
            {
                
GivePlayerCash(playerid, -500);
                
GivePlayerValidWeapon(playerid2560000);
                
format(stringsizeof(string), "Pumped Shotgun Purchase.");
                
SendClientMessageEx(playeridCOLOR_REDstring);
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this item!");
            }
this line>>            else
            {
                
SendClientMessageEx(playeridCOLOR_GRAD4"You need to be gold vip +!");
            }
        } 



Re: What is wrong with this ? - JaydenJason - 17.07.2015

You can't have two "else" statements for one "if", give it a thought

if(level > 1)
blabla

else [if level is < 1]
blabla

else [if level is > 1?]


Re: What is wrong with this ? - liquor - 17.07.2015

There are no conditions before the 'else'. You need to edit your message to "You don't have the cash OR you don't have a donate rank fo atleast 3".


Or you need to make a separate condition ('if' statement) for donate rank.


Re: What is wrong with this ? - IndependentGaming - 17.07.2015

so like:

PHP код:
if(listitem == 0)
        {
            if (
GetPlayerCash(playerid) >= 500){
            if (
PlayerInfo[playerid][pDonateRank] >= 3)
            {
                
GivePlayerCash(playerid, -500);
                
GivePlayerValidWeapon(playerid2560000);
                
format(stringsizeof(string), "Pumped Shotgun Purchase.");
                
SendClientMessageEx(playeridCOLOR_REDstring);
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this item!");
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GRAD4"You need to be gold vip +!");
            }
        } 



Re: What is wrong with this ? - liquor - 17.07.2015

Try it


Re: What is wrong with this ? - BladeFire - 17.07.2015

PHP код:
if(listitem == 0)
        {
            if (
GetPlayerCash(playerid) >= 500 || PlayerInfo[playerid][pDonateRank] >= 3) {
                
GivePlayerCash(playerid, -500);
                
GivePlayerValidWeapon(playerid2560000);
                
format(stringsizeof(string), "Pumped Shotgun Purchase.");
                
SendClientMessageEx(playeridCOLOR_REDstring);
            }
            else
            {
               
SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this item or You need to be gold vip +!");
            }
            
        } 
I suggest you do this


Re: What is wrong with this ? - IndependentGaming - 17.07.2015

Quote:
Originally Posted by BladeFire
Посмотреть сообщение
PHP код:
if(listitem == 0)
        {
            if (
GetPlayerCash(playerid) >= 500 || PlayerInfo[playerid][pDonateRank] >= 3) {
                
GivePlayerCash(playerid, -500);
                
GivePlayerValidWeapon(playerid2560000);
                
format(stringsizeof(string), "Pumped Shotgun Purchase.");
                
SendClientMessageEx(playeridCOLOR_REDstring);
            }
            else
            {
               
SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this item or You need to be gold vip +!");
            }
            
        } 
I suggest you do this
this is not working only for the cash but not for the vip.


Re: What is wrong with this ? - M4D - 17.07.2015

PHP код:
if(listitem == 0)
{
    if(
GetPlayerCash(playerid) < 500) return SendClientMessageEx(playeridCOLOR_GRAD4"You don't have the cash for this item or You need to be gold vip +!");
    if(
PlayerInfo[playerid][pDonateRank] < 3) return SendClientMessageEx(playeridCOLOR_GRAD4"You need to be gold vip +!");
    
GivePlayerCash(playerid, -500);
    
GivePlayerValidWeapon(playerid2560000);
    
format(stringsizeof(string), "Pumped Shotgun Purchase.");
    
SendClientMessageEx(playeridCOLOR_REDstring);