SA-MP Forums Archive
command isn't working... - 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: command isn't working... (/showthread.php?tid=617860)



command isn't working... - IndependentGaming - 27.09.2016

Hello, I'm making a few new commands but getting a error and I cant find the problem ?


warning:
Код:
Roleplay\gamemodes\RP.pwn(23697) : warning 217: loose indentation
Roleplay\gamemodes\RP.pwn(23705) : warning 225: unreachable code
Roleplay\gamemodes\RP.pwn(23705) : warning 217: loose indentation
Roleplay\gamemodes\RP.pwn(23705) : error 029: invalid expression, assumed zero
Roleplay\gamemodes\RP.pwn(23706) : warning 217: loose indentation


1 Error.

Command:

PHP код:
CMD:giveweaponlic(playeridparams[])
{
    new 
giveplayeridstring[125];
    if(
PlayerInfo[playerid][pFaction] == || PlayerInfo[playerid][pLeader] == 1)
    {
        if(
PlayerInfo[giveplayerid][pGunLic] == 1)
          {
            
SendClientMessage(playeridCOLOR_GRAD2"This player already has a weapon license.");
        }
            
format(stringsizeof(string), "You have given a weapon license to %s.",GetPlayerNameEx(giveplayerid));
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
format(stringsizeof(string), "Officer %s has given you a weapon license.",GetPlayerNameEx(playerid));
            
SendClientMessage(giveplayeridCOLOR_WHITEstring);
            
format(stringsizeof(string), "Officer %s has given a weapon license to %s.",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid));
            
Log("logs/licenses.log"string);
            
PlayerInfo[giveplayerid][pGunLic] = 1;
            return 
1;
    else
        {
            
SendClientMessage(playeridCOLOR_WHITE"You are not a police officer!");
        }
    }
    return 
1;




Re: command isn't working... - SyS - 27.09.2016

PHP код:
CMD:giveweaponlic(playeridparams[]) 

    new 
giveplayeridstring[125]; 
    if(
PlayerInfo[playerid][pFaction] == || PlayerInfo[playerid][pLeader] == 1
    { 
        if(
PlayerInfo[giveplayerid][pGunLic] == 1
          { 
            
SendClientMessage(playeridCOLOR_GRAD2"This player already has a weapon license."); 
           } 
            
format(stringsizeof(string), "You have given a weapon license to %s.",GetPlayerNameEx(giveplayerid)); 
            
SendClientMessage(playeridCOLOR_WHITEstring); 
            
format(stringsizeof(string), "Officer %s has given you a weapon license.",GetPlayerNameEx(playerid)); 
            
SendClientMessage(giveplayeridCOLOR_WHITEstring); 
            
format(stringsizeof(string), "Officer %s has given a weapon license to %s.",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid)); 
            
Log("logs/licenses.log"string); 
            
PlayerInfo[giveplayerid][pGunLic] = 1
            return 
1
       else 
         { 
            return 
SendClientMessage(playeridCOLOR_WHITE"You are not a police officer!"); 
          } 
     } 
     return 
1




Re: command isn't working... - IndependentGaming - 27.09.2016

Problem sloved.


Re: command isn't working... - Konstantinos - 27.09.2016

Returning a value there (after "PlayerInfo[giveplayerid][pGunLic] = 1;") is wrong. It should have been a closed bracket and you should remove the bracket above the last "return 1;".
pawn Код:
if (PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pLeader] == 1)
{
    // code..
}
else
{
    SendClientMessage(playerid, COLOR_WHITE, "You are not a police officer!");
}
"giveplayerid" is 0, you forgot to use sscanf, check if the player is connected etc.


Re: command isn't working... - SyS - 27.09.2016

Quote:
Originally Posted by SacrificeGaming
Посмотреть сообщение
Roleplay\gamemodes\RP.pwn(23697) : warning 217: loose indentation
Roleplay\gamemodes\RP.pwn(23705) : warning 225: unreachable code
Roleplay\gamemodes\RP.pwn(23705) : warning 217: loose indentation
Roleplay\gamemodes\RP.pwn(23705) : error 029: invalid expression, assumed zero
Roleplay\gamemodes\RP.pwn(23706) : warning 217: loose indentation
Roleplay\gamemodes\RP.pwn(23710) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
wait little bit -_- i posted wrong thing i accidently clicked on post button (i didnt change anything just simple lines and indenting and was studying your logic) you should close that if statement man before returning
and i noticed that your code wont give you anything and wont work as you need to.the use of sscanf is required there.
PHP код:
CMD:giveweaponlic(playeridparams[])
{
    new 
giveplayeridstring[125];
    if (
sscanf(params"u"giveplayerid))
        return 
SendClientMessage(playeridCOLOR_WHITE"/giveweaponlic playerid");
    if (
PlayerInfo[playerid][pFaction] == || PlayerInfo[playerid][pLeader] == 1)
    {
        if (
PlayerInfo[giveplayerid][pGunLic] == 1)
            return 
SendClientMessage(playeridCOLOR_GRAD2"This player already has a weapon license.");
        
format(stringsizeof(string), "You have given a weapon license to %s."GetPlayerNameEx(giveplayerid));
        
SendClientMessage(playeridCOLOR_WHITEstring);
        
format(stringsizeof(string), "Officer %s has given you a weapon license.",
        
GetPlayerNameEx(playerid));
        
SendClientMessage(giveplayeridCOLOR_WHITEstring);
        
format(stringsizeof(string), "Officer %s has given a weapon license to %s.",
        
GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
        
Log("logs/licenses.log"string);
        
PlayerInfo[giveplayerid][pGunLic] = 1;
        return 
1;
    }
    else
    {
        return 
SendClientMessage(playeridCOLOR_WHITE"You are not a police officer!");
    }
    return 
1;

about indentation warnings just pretty print it.(i think i indented it )