SA-MP Forums Archive
Help! unreachable 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! unreachable code (/showthread.php?tid=246696)



Help! unreachable code - martini002 - 05.04.2011

Dear all

im puting a code into my gm
for anti cheat money, but im having a bit problem
so im big ignorant of pawn script, bit still learning

so can you help me with this?
what im doing bad?

Thanks

Код:
public OnPlayerUpdate(playerid)
{
	if(!IsPlayerConnected(playerid)) return 0;
	// No weapons in interiors
	if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
	    SetPlayerArmedWeapon(playerid,0); // fists
	    return 0; // no syncing until they change their weapon
	}
	return 1;
	{ //---------------------------------------------------------------------------------------------LINE 23599---//
		if(GetPlayerMoneyEx(playerid) != GetPlayerMoney(playerid))
		{
		new const old_money = GetPlayerMoneyEx(playerid);
		ResetPlayerMoneyEx(playerid), GivePlayerMoneyEx(playerid, old_money);
		}
		return 1;
	}
}
Код:
G:\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\SATDM_v10.pwn(22599) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.



Respuesta: Help! unreachable code - Daniel-92 - 05.04.2011

The code would be well
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!IsPlayerConnected(playerid)) return 0;
    // No weapons in interiors
    if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
        SetPlayerArmedWeapon(playerid,0); // fists
        return 0; // no syncing until they change their weapon
     }
    if(GetPlayerMoneyEx(playerid) != GetPlayerMoney(playerid))
     {
        new const old_money = GetPlayerMoneyEx(playerid);
        ResetPlayerMoneyEx(playerid), GivePlayerMoneyEx(playerid, old_money);
     }
    return 1;
 }



Re: Help! unreachable code - Dark_Kostas - 05.04.2011

There is a "return 1;" before the if statement of GetPlayerMoneyEx. Also why do you need the extra 2 brackets after this return and the semi-last one?


Re: Help! unreachable code - Calgon - 05.04.2011

OnPlayerUpdate is ONLY called if the player is connected, so:
pawn Код:
if(!IsPlayerConnected(playerid)) return 0;
is redundant.


Re: Respuesta: Help! unreachable code - martini002 - 05.04.2011

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
The code would be well
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!IsPlayerConnected(playerid)) return 0;
    // No weapons in interiors
    if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
        SetPlayerArmedWeapon(playerid,0); // fists
        return 0; // no syncing until they change their weapon
     }
    if(GetPlayerMoneyEx(playerid) != GetPlayerMoney(playerid))
     {
        new const old_money = GetPlayerMoneyEx(playerid);
        ResetPlayerMoneyEx(playerid), GivePlayerMoneyEx(playerid, old_money);
     }
    return 1;
 }
Thanks very much for your help dude, now compiled good! so i hope this code work then


Re: Help! unreachable code - martini002 - 05.04.2011

and thanks to all too! now i learning a new thing