Help! unreachable code
#1

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

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;
 }
Reply
#3

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?
Reply
#4

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

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
Reply
#6

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


Forum Jump:


Users browsing this thread: 7 Guest(s)