Callback
#16

The whole code is an example. (This include is about detect when a player use Pay'n'Spray to repair vehicle):
PHP код:
hook OnPlayerUpdate(playerid)
{
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER
    {
        for(new 
sizeof(PayNSprayPos) - 1>= 0i--)
        {
            if(
IsPlayerInRangeOfPoint(playerid3.3PayNSprayPos[i][0], PayNSprayPos[i][1], PayNSprayPos[i][2]) && GetPlayerMoney(playerid) >= 100)
            {
                static
                    
Float:x,
                    
Float:y,
                    
Float:z;
                
GetPlayerPos(playeridxyz);
                if(
p_A_Flood[playerid] < gettime())
                    
p_Timer[playerid] = SetTimerEx("Ji_Timer_PNS"100true"iifff"playeridGetPlayerVehicleID(playerid), xyz);
            }
        }
    }
}
forward Ji_Timer_PNS(playeridvehicleidFloat:xFloat:yFloat:z);
public 
Ji_Timer_PNS(playeridvehicleidFloat:xFloat:yFloat:z)
{
    static 
        
Float:Pos[3],
        
Float:vHP;
    
GetVehicleHealth(vehicleidvHP);
    
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
    if(
== Pos[0] && == Pos[1] && == Pos[2])
    {
        if(
p_A_Flood[playerid] > gettime())
            return 
1;
        
        new 
v_Color1[vehicleid] ? -random(255),
            
v_Color2[vehicleid] ? -random(255);
        
p_A_Flood[playerid] = gettime() + TEMPS_MOYEN;
        
p_Timer[playerid] = 0;
        
KillTimer(p_Timer[playerid]);
        if(!
v_Color1[vehicleid] && !v_Color2[vehicleid])
        {
            
ChangeVehicleColor(vehicleidab);
        }
        
vHP 1000.0 vHP;
        
CallLocalFunction("Ji_OnCarResprayAtPNS""iiiif"playeridGetPlayerVehicleID(playerid), abvHP <= 0.00 0.00 vHP);
    }
    return 
1;
}
forward Ji_OnCarResprayAtPNS(playeridvehicleidcolor1color2Float:hp_recovered); 
In your gamemode where there is your include:

PHP код:
public Ji_OnCarResprayAtPNS(playeridvehicleidcolor1color2Float:hp_recovered)
{
    
AdminWarn("[DEBUG] playerid: %i, vehicleid: %i, color1: %i, color2: %i, hp_recovered: %0.3f"playeridvehicleidcolor1color2hp_recovered);
    if(
hp_recovered 280.0)
    {
        foreach(new 
Player)
        {
            if(
== playerid || !IsPlayerInAnyVehicle(i))
                continue;
            if(
GetPlayerVehicleID(i) == vehicleid)
            {
                
SCM(i0xff00ffff"[REPARATION] {e699ff}Your have to pay 100$ too.");
                
GivePlayerMoney(i, -100);
            }
        }
    }
    return 
1;

Reply


Messages In This Thread
Callback - by JaKe Elite - 19.08.2017, 14:32
Re: Callback - by DimaShift - 19.08.2017, 15:04
Re: Callback - by JaKe Elite - 19.08.2017, 15:28
Re: Callback - by JaKe Elite - 19.08.2017, 21:57
Re: Callback - by Misiur - 19.08.2017, 22:37
Re: Callback - by JaKe Elite - 20.08.2017, 08:03
Re: Callback - by Logic_ - 20.08.2017, 08:06
Re: Callback - by JaKe Elite - 20.08.2017, 08:11
Re: Callback - by JaKe Elite - 20.08.2017, 09:52
Re: Callback - by JaKe Elite - 20.08.2017, 13:01
Re: Callback - by TheCman - 20.08.2017, 13:06
Re: Callback - by JaKe Elite - 20.08.2017, 13:12
Re: Callback - by TheCman - 20.08.2017, 13:13
Re: Callback - by JaKe Elite - 20.08.2017, 13:22
Re: Callback - by JaKe Elite - 20.08.2017, 13:28
Re: Callback - by Dayrion - 20.08.2017, 13:46
Re: Callback - by TheCman - 20.08.2017, 14:13
Re: Callback - by JaKe Elite - 20.08.2017, 14:30
Re: Callback - by Dayrion - 20.08.2017, 14:53
Re: Callback - by TheCman - 20.08.2017, 15:09
Re: Callback - by Dayrion - 20.08.2017, 15:39
Re: Callback - by GoldenLion - 20.08.2017, 16:25
Re: Callback - by TheCman - 20.08.2017, 16:33

Forum Jump:


Users browsing this thread: 4 Guest(s)