OnPlayerUpdate [+REPS] - 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: OnPlayerUpdate [+REPS] (
/showthread.php?tid=505173)
OnPlayerUpdate [+REPS] -
SPA - 07.04.2014
Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInRangeOfPoint(playerid,15.0,382.4741,2548.9509,20.1041))
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.2, 0.2, 0.2);
}
}
if(IsPlayerInRangeOfPoint(playerid,15.0,-1185.4705,27.1411,17.6159))
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.2, 0.2, 0.2);
}
}
new InfoString[512];
if(IsPlayerConnected(playerid))
{
if(GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) < 10)
{
State[playerid] = "Noob";
}
if(GetPlayerScore(playerid) >= 10 && GetPlayerScore(playerid) < 50)
{
State[playerid] = "Newbie";
}
if(GetPlayerScore(playerid) >= 51 && GetPlayerScore(playerid) < 101)
{
State[playerid] = "Hero";
}
if(GetPlayerScore(playerid) >= 101 && GetPlayerScore(playerid) < 501)
{
State[playerid] = "Adviser";
}
if(GetPlayerScore(playerid) >= 501 && GetPlayerScore(playerid) < 2001)
{
State[playerid] = "Judge";
}
if(GetPlayerScore(playerid) >= 2001 && GetPlayerScore(playerid) < 5001)
{
State[playerid] = "Advanced";
}
if(GetPlayerScore(playerid) >= 5001 && GetPlayerScore(playerid) < 10001)
{
State[playerid] = "Dominator";
}
if(GetPlayerScore(playerid) >= 10001 && GetPlayerScore(playerid) < 100001)
{
State[playerid] = "King";
}
if(GetPlayerScore(playerid) >= 100001)
{
State[playerid] = "Minister";
}
if(IsPlayerNPC(playerid)) return 0;
format(InfoString, sizeof(InfoString), "Kills: ~w~~W~%d~N~~r~Deaths: ~W~%d~N~~P~Ratio:~W~ %0.2f~N~~Y~Score: ~W~%d~N~~g~Rank:~W~ %s", pInfo[playerid][Kills],pInfo[playerid][Deaths],Float:pInfo[playerid][Kills]/Float:pInfo[playerid][Deaths],GetPlayerScore(playerid),State[playerid]);
TextDrawSetString(PPing[playerid], InfoString);
}
#if PauseDetectSystem == true
pTick[playerid] = GetTickCount();
#endif
#if MoveSystem == true
if(pInfo[playerid][Move] == 1)
GetPlayerHoldingKey(playerid);
#endif
return 1;
}
Does this code make server lags ? its like a textdraws stats
Re: OnPlayerUpdate [+REPS] -
ChuckyBabe - 07.04.2014
NO.. +rep if i help
Re: OnPlayerUpdate [+REPS] -
SPA - 07.04.2014
Bump
Re: OnPlayerUpdate [+REPS] -
iBanner - 07.04.2014
I think no. Unless you put timer and some other complicated stuff.
Re: OnPlayerUpdate [+REPS] -
Vince - 07.04.2014
Unlikely, but use the profiler plugin to be sure. There IS a lot of room for optimizations, however. Using a switch statement can reduce unnecessary calls to GetPlayerScore by 95%. IsPlayerConnected is also a completely redundant function call because callbacks are obviously only called if the player is connected.
But still, it'd be better to move the score part to a separate function entirely and invoke it whenever you use SetPlayerScore. You could write a hook to do it automatically.
PS: @ChuckyBabe above: use another avatar. Stealing the avatar of a reputable member is frankly just arrogant.
Re: OnPlayerUpdate [+REPS] -
SPA - 07.04.2014
thnx so its not lag +rep