Is this OnPlayerUpdate code efficiant?
#1

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

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

No that won't work.
Reply
#4

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));
Reply
#5

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)