3 Errors
#2

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
Float:H;
    
GetPlayerHealth(playerid,H);
    if(
H<99)
    {
        
SetPlayerHealth(playerid,100);
        return 
1;
    }
       if(
IsPlayerConnected(playerid))
       {
        
GetVehicleHealth(GetPlayerVehicleID(playerid), H);
        if(
1000)
        {
            
SetVehicleHealth(GetPlayerVehicleID(playerid),1000);
        }
    }
    return 
1;

Here's correct code.

I should notice though, this is some very bad scripting for the following reasons:

1. You use OnPlayerUpdate to fix cars and heal players, and at 99% health? Use a timer instead, since OPU checks every 20ms which is way too fast for anything.
2. You do a loop through all players in OPU? Why? Its already checking for all players seperate.

You should read up on pawno a little more, this snippet was awfully inefficient, it would work but your server would lagg if you ever got a little more people on.

EDIT: Here's a more efficient code that works just as good but doesn't require nearly as much CPU.

PHP код:
new healtimer[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
healtimer[playerid] = SetTimerEx("HealTimer"1000/* Time in milliseconds*/1/*repeating*/"%d"playerid);
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
KillTimer(healtimer[playerid]);
    return 
1;
}
forward HealTimer(playerid);
public 
HealTimer(playerid);
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:H;
        
GetPlayerHealth(playerid,H);
        if(
H<90SetPlayerHealth(playerid,100);
        
GetVehicleHealth(GetPlayerVehicleID(playerid), H);
        if(
H<900SetVehicleHealth(GetPlayerVehicleID(playerid),1000);
    }
    return 
1;

Reply


Messages In This Thread
3 Errors - by nuriel8833 - 22.04.2011, 14:58
Re: 3 Errors - by Sinner - 22.04.2011, 15:09
Re: 3 Errors - by nuriel8833 - 22.04.2011, 15:12
Re: 3 Errors - by Sinner - 22.04.2011, 15:15
Re: 3 Errors - by nuriel8833 - 22.04.2011, 15:26
Re: 3 Errors - by Sinner - 22.04.2011, 15:49

Forum Jump:


Users browsing this thread: 1 Guest(s)