SA-MP Forums Archive
1 Error 2 Warns - 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: 1 Error 2 Warns (/showthread.php?tid=532826)



1 Error 2 Warns - weedxd - 20.08.2014

PHP код:
C:\Users\WeeD\Desktop\LSC-RP\gamemodes\LSC-RP.pwn(18093) : warning 225: unreachable code
C
:\Users\WeeD\Desktop\LSC-RP\gamemodes\LSC-RP.pwn(18162) : warning 225: unreachable code
C
:\Users\WeeD\Desktop\LSC-RP\gamemodes\LSC-RP.pwn(18162) : error 017: undefined symbol "f"
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase 
PHP код:

18093    
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]");
18162    if(f) 
I dunno how to fix these :/ I want to get the server up and running but these are the left ones which are cousing problems ;/


Re: 1 Error 2 Warns - Stinged - 20.08.2014

Show us the whole code.


Re: 1 Error 2 Warns - weedxd - 20.08.2014

More info of the situation.

Whole server script here. http://paste2.org/d1adZ3cB

PHP код:
CMD:aname(playerid, params[])
{
    new 
string[128], file[32], text[MAX_PLAYER_NAME];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    return 
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
18093    if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]");
    if(
aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
    if(
strlen(text) < 2) return SendClientMessage(playerid, COLOR_GREY, "The admin name needs to be atleast 2 characters.");
    
// Start of detecting space in name
    
new end, temp[32], temp2[32];
    
end = strfind(text, " ",true);
    if(
end != -1)
    {
        
strmid(temp, text, 0, end);
        
format(temp, sizeof(temp), "%s_", temp);
        
strdel(text, 0, end);
        
strmid(temp2, text, 1, strlen(text));
        
format(text, 24, "");
        
strcat(text, temp, sizeof(temp));
        
strcat(text, temp2, sizeof(temp2));
    }
    
// End of detecting space in name
    
format(file, sizeof(file), "users/%s.ini", text);
    if(
dini_Exists(file))
    {
        
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        if(
strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
        {
             
SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
            return 
1;
        }
    }
    
format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
    
SendClientMessage(playerid, COLOR_WHITE, string);
    
format(string, sizeof(string), "%s has changed their admin name to %s.", RPN(playerid), text);
    
Log("logs/aname.log", string);
    
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
    
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
    if(
dini_Exists(file)) dini_Remove(file);
    
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
    
dini_Set(file, "AdminName", text);
    
format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
    
dini_Create(file);
    
dini_Set(file, "OldName", RPNU(playerid));
    
dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
    
dini_IntSet(file, "AdminAccount", 1);
    
dini_IntSet(file, "Age", 25);
    
dini_IntSet(file, "Gender", 1);
    
dini_IntSet(file, "Tutorial", 1);
    
dini_Set(file, "IP", PlayerInfo[playerid][pIP]);
    return 
1;
} 
PHP код:
CMD:aduty(playerid, params[])
{
    new 
string[128], file[32];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    return 
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
18162    if(f)
    {
        
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
        if(!
dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Choose an admin name using /aname first.");
        
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        
format(string, sizeof(string), "AdmWarn: %s has went on admin duty. (Admin name: %s)", RPN(playerid), dini_Get(file, "AdminName"));
        
SendAdminMessage(COLOR_DARKRED, 1, string);
        
SaveChar(playerid);
        
ClearChar(playerid);
        
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        
SetPlayerName(playerid, dini_Get(file, "AdminName"));
        
LoadChar(playerid);
        
aDuty[playerid] = 1;
        
SpawnChar(playerid);
        
GetPlayerIp(playerid, PlayerInfo[playerid][pIP], 16);
        
format(string, sizeof(string), "%s", RPALN(playerid));
        if(
IsValidDynamic3DTextLabel(aDutyText[playerid]))  DestroyDynamic3DTextLabel(aDutyText[playerid]);
        if(
PlayerInfo[playerid][pAdmin] == 1) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_LIGHTGREEN, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 2) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_LIME, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 3) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 4) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_ORANGE, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 5) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_RED, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 6) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_DARKRED, 0, 0, -20, 25, playerid);
        if(
PlayerInfo[playerid][pAdmin] == 7) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_DARKRED, 0, 0, -20, 25, playerid);
        
Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, aDutyText[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.25);
    }
    else
    {
        if(
Spec[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You can't go off admin duty while spectating someone.");
        
format(file, sizeof(file), "users/%s.ini",RPNU(playerid));
        
SaveChar(playerid);
        
ClearChar(playerid);
        
SetPlayerName(playerid, dini_Get(file, "OldName"));
        
LoadChar(playerid);
        
aDuty[playerid] = 0;
        
SpawnChar(playerid);
        
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        
format(string, sizeof(string), "AdmWarn: %s has went off admin duty. (Admin name: %s)", RPN(playerid), dini_Get(file, "AdminName"));
        
SendAdminMessage(COLOR_DARKRED, 1, string);
        
DestroyDynamic3DTextLabel(aDutyText[playerid]);
    }
    return 
1;
} 



Re: 1 Error 2 Warns - weedxd - 20.08.2014

Bump. I rly need help on this.


Re: 1 Error 2 Warns - SAMProductions - 21.08.2014

Try to add a semicolon ";" in,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]")
For Example,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]");



Re: 1 Error 2 Warns - ThePhenix - 21.08.2014

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
Try to add a semicolon ";" in,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]")
For Example,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]");
EDIT: The poster above already gave the answer.


Re: 1 Error 2 Warns - Stinged - 21.08.2014

Your "unreachable code" warning is because you have returned something under if(..)


Re: 1 Error 2 Warns - Stinged - 21.08.2014

Quote:
Originally Posted by Marsss
Посмотреть сообщение
#Define f

REP Me please
This will only hide the warning and bug the code!


Re: 1 Error 2 Warns - weedxd - 21.08.2014

Quote:
Originally Posted by Stinged
Посмотреть сообщение
This will only hide the warning and bug the code!
Yeah i know that thats the reason why i didnt #define it.

Is there a way how to fix it ?


Re: 1 Error 2 Warns - weedxd - 21.08.2014

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
Try to add a semicolon ";" in,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]")
For Example,
Код:
if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /aname [name]");
Thanks for your help