SA-MP Forums Archive
Is this OnPlayerUpdate code efficiant? - 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: Is this OnPlayerUpdate code efficiant? (/showthread.php?tid=245289)



Is this OnPlayerUpdate code efficiant? - linuxthefish - 30.03.2011

As the title says. BTW there can be around 20 people who will have godmode on 1.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(godmode[playerid] == 1)
    {
        SetPlayerHealth(playerid, 200);
        SetPlayerArmour(playerid, 200);
        RepairVehicle(GetPlayerVehicleID(playerid));
    }
return 0;
}



Re: Is this OnPlayerUpdate code efficiant? - KaleOtter - 30.03.2011

You also can use
SetPlayerHealth(playerid, 9999);
SetPlayerArmour(playerid, 9999);

In a slower timer like 1 minut or something I gues.
But I gues it won't cause lag if you have this for around 20 players.


Re: Is this OnPlayerUpdate code efficiant? - WackoX - 30.03.2011

No that won't work.


Re: Is this OnPlayerUpdate code efficiant? - Cameltoe - 30.03.2011

Quote:
Originally Posted by linuxthefish
Посмотреть сообщение
As the title says. BTW there can be around 20 people who will have godmode on 1.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(godmode[playerid] == 1)
    {
        SetPlayerHealth(playerid, 200);
        SetPlayerArmour(playerid, 200);
        RepairVehicle(GetPlayerVehicleID(playerid));
    }
return 0;
}
You are better off using an timer, also :

pawn Код:
if(IsPlayerInAnyVehicle(playerid)) RepairVehicle(GetPlayerVehicleID(playerid));



Re: Is this OnPlayerUpdate code efficiant? - KaleOtter - 30.03.2011

Quote:
Originally Posted by WackoX
Посмотреть сообщение
No that won't work.
Won't it? ow well I'm sorry about that, never used something like that hehe :P


Re: Is this OnPlayerUpdate code efficiant? - mprofitt - 30.03.2011

Quote:
Originally Posted by linuxthefish
Посмотреть сообщение
As the title says. BTW there can be around 20 people who will have godmode on 1.
pawn Код:
public OnPlayerUpdate(playerid)
{
if(godmode[playerid] == 1)
    {
        SetPlayerHealth(playerid, 200);
        SetPlayerArmour(playerid, 200);
        RepairVehicle(GetPlayerVehicleID(playerid));
    }
return 0;
}
I see nothing wrong with it. These guy who want nothing in OnPlayerUpdate are just overly cautious.


Re: Is this OnPlayerUpdate code efficiant? - Cameltoe - 30.03.2011

Quote:
Originally Posted by mprofitt
Посмотреть сообщение
I see nothing wrong with it. These guy who want nothing in OnPlayerUpdate are just overly cautious.
Really? OnPlayerUpdate is called (32?) times pr. second.

Calling that code 32 * 20 players each seconds is inefficient.


Re: Is this OnPlayerUpdate code efficiant? - iggy1 - 30.03.2011

You can just give god mode by doing the following,
pawn Код:
SetPlayerHealth( playerid, 999999);//god mode
SetVehicleHealth(GetPlayerVehicleID(playerid), 999999);//car god
And use a timer to repair the vehicle damage.


Re: Is this OnPlayerUpdate code efficiant? - admantis - 30.03.2011

It depends of what are you doing, it's different to set a player health than saving a bunch of files with Dini.


Re: Is this OnPlayerUpdate code efficiant? - mprofitt - 30.03.2011

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Really? OnPlayerUpdate is called (32?) times pr. second.

Calling that code 32 * 20 players each seconds is inefficient.
Please show me documented proof OnPlayerUpdate is called 32 times a second, just for my curiosity.