command isn't working...
#1

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;

Reply
#2

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

Reply
#3

Problem sloved.
Reply
#4

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)