09.05.2011, 16:14
I see big mistakes!
Here's the correct code:
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 500 // Change 500 to your server's playerslots.
// Why is this needed?
...
public OnPlayerUpdate(playerid)
{
new ZmoneyZ[MAX_PLAYERS]; // Are you serious? This is stupid!
if(GetPlayerMoney(playerid) != OPMCMoney[playerid]) // 1
{
ZmoneyZ[playerid] = GetPlayerMoney(playerid)-OPMCMoney[playerid]; // 2
CallLocalFunction("OnPlayerMoneyChange", "ii", playerid, ZmoneyZ[playerid]);
OPMCMoney[playerid] = GetPlayerMoney(playerid); // 3 - You use GetPlayerMoney function 3 times, when you can store it in a variable.
}
return (PlayerUP)?CallLocalFunction("Inc_OnPlayerUpdate","i", playerid):1;
}
pawn Код:
public OnPlayerUpdate(playerid)
{
new P_Money = GetPlayerMoney(playerid);
if(P_Money != OPMCMoney[playerid])
{
CallLocalFunction("OnPlayerMoneyChange", "ii", playerid, (P_Money - OPMCMoney[playerid]));
OPMCMoney[playerid] = P_Money;
}
return (PlayerUP)?CallLocalFunction("Inc_OnPlayerUpdate","i", playerid):1;
}