SA-MP Forums Archive
What is wrong in that code - 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 in that code (/showthread.php?tid=337521)



What is wrong in that code - boyan96 - 26.04.2012

what is wrong here because the script didn't work

PHP код:
else if(PlayerInfo[playerid][pMember] == TEAM_CIVILIAN)
    {
       if(
GetPlayerScore(playerid) < 15)
         {
        
GivePlayerGun(playerid33);//tec9
        
GivePlayerGun(playerid23);//deagle
        
}
        if(
GetPlayerScore(playerid) > 50000)
        
GivePlayerGun(playerid26);//sawn
        
GivePlayerGun(playerid32);//tec
    




Re: What is wrong in that code - Elysian` - 26.04.2012

PHP код:
else if(PlayerInfo[playerid][pMember] == TEAM_CIVILIAN)
    {
       if(
GetPlayerScore(playerid) < 15)
         {
              
SetPlayerWeapon(playerid33);//tec9
              
SetPlayerWeapon(playerid23);//deagle
        
}
        if(
GetPlayerScore(playerid) > 50000)
              
SetPlayerWeapon(playerid26);//sawn
              
SetPlayerWeapon(playerid32);//tec
    




Re: What is wrong in that code - ViniBorn - 26.04.2012

Quote:
Originally Posted by Windows32
Посмотреть сообщение
PHP код:
else if(PlayerInfo[playerid][pMember] == TEAM_CIVILIAN)
    {
       if(
GetPlayerScore(playerid) < 15)
         {
              
SetPlayerWeapon(playerid33);//tec9
              
SetPlayerWeapon(playerid23);//deagle
        
}
        if(
GetPlayerScore(playerid) > 50000)
              
SetPlayerWeapon(playerid26);//sawn
              
SetPlayerWeapon(playerid32);//tec
    

SetPlayerWeapon ?

GivePlayerWeapon


Re: What is wrong in that code - Elysian` - 26.04.2012

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
SetPlayerWeapon ?

GivePlayerWeapon
Sorry that's what I meant.


Re: What is wrong in that code - [KHK]Khalid - 26.04.2012

I'm surprised that compiles or works. if(GetPlayerScore(playerid) > 50000) has no brackets

pawn Код:
if(GetPlayerScore(playerid) > 50000)
              GivePlayerGun(playerid, 26);//sawn
              GivePlayerGun(playerid, 32);//tec
has to be

pawn Код:
if(GetPlayerScore(playerid) > 50000)
{
    GivePlayerGun(playerid, 26);//sawn
    GivePlayerGun(playerid, 32);//tec
}
and use GivePlayerWeapon to give a weapon to a player unless you've made a stock for GivePlayerGun


Re: What is wrong in that code - Falco-Ger - 26.04.2012

when you dont put brackets after an if, that if will only affect the next line

Код:
if (a == 1)
    command1;
command2;
command 2 will allways be executed
if u make use of this, please use tabs accordingly

anyway i suggest to allways put brackets, even if there is only one command after the if, because it's confusing and it can cause problems when you want to add something to it and you dont remember to put the brackets after that.
especialy if your compiler outputs shows you 300 warnings about "loosing identication" allready