View difference between Paste ID: HHAp9LAJ and wc0PcmwM
SHOW: | | - or go back to the newest paste.
1
#if !defined Function
2
	#define Function::%0(%1)    %0(%1); public %0(%1)
3-
stock Float:GetDistanceVehicleFromPoint(vehicleid,float:pontox,float:pontoy,float:pontoz)
3+
#endif
4
forward ModeInit();
5-
	new Float:x,Float:y,Float:z;
5+
forward StateChange(playerid, newstate, oldstate);
6-
	GetVehiclePos(vehicleid,x1,y1,z1);
6+
7-
	return floatsqroot(floatpower(floatabs(floatsub(pontox,x)),2)+floatpower(floatabs(floatsub(pontoy,y)),2)+floatpower(floatabs(floatsub(pontoz,z)),2));
7+
8
stock GetDistanceTraveled(vehicleid)
9-
stock GetDistanceTraveled(vehicleid) return Percorreu[vehicleid];
9+
10
     Corrida(vehicleid);
11
     return Percorreu[vehicleid];
12
}
13
public OnGameModeInit()
14
{
15-
	   GetVehiclePos(v,VehicleX[v],VehicleY[v],VehicleZ[v]);
15+
    SetTimer("GetPositionAll",3000,false);
16
    return CallLocalFunction("ModeInit", "");
17
}
18
Function::GetPositionAll()
19-
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
19+
20
    for(new v; v < MAX_VEHICLES; v++)
21-
    Timer[vehicleid] = SetTimerEx("Corrida",2000,true,"i",vehicleid);
21+
22
           if(GetVehicleModel(v) != 0) GetVehiclePos(v,VehicleX[v],VehicleY[v],VehicleZ[v]);
23
    }
24-
public OnPlayerExitVehicle(playerid, vehicleid)
24+
25
}
26-
    KillTimer(Timer[vehicleid]);
26+
public OnPlayerStateChange(playerid, newstate, oldstate)
27
{
28
    if(oldstate == PLAYER_STATE_DRIVER)
29-
public forward Corrida(vehicleid)
29+
30
        KillTimer(Timer[GetPlayerVehicleID(playerid)]);
31-
	Percorreu[vehicleid] += GetDistanceVehicleFromPoint(vehicleid,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
31+
32
    if(newstate == PLAYER_STATE_DRIVER)
33
    {
34
    	Timer[GetPlayerVehicleID(playerid)] = SetTimerEx("Corrida",5000,true,"i",GetPlayerVehicleID(playerid));
35
    }
36
    return CallLocalFunction("StateChange", "iii",playerid, newstate, oldstate);
37
}
38
Function::Corrida(vehicleid)
39
{
40
	Percorreu[vehicleid] += GetVehicleDistanceFromPoint(vehicleid,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
41
	GetVehiclePos(vehicleid,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
42-
}
42+
43
}
44
stock SetVehiclePosEx(vehicleid,float:X,float:Y,float:Z)
45
{
46
	SetVehiclePos(vehicleid,X,Y,Z);
47
  	VehicleX[vehicleid] = X;
48
	VehicleY[vehicleid] = Y;
49
	VehicleZ[vehicleid] = Z;
50
	return 1;
51
}
52
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
53
{
54
    new ID = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
55
    GetVehiclePos(ID,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
56
    return 1;
57
}
58
#if defined _ALS_OnGameModeInit
59
    #undef OnGameModeInit
60
#else
61
    #define _ALS_OnGameModeInit
62
#endif
63
#if defined _ALS_OnPlayerStateChange
64
    #undef OnPlayerStateChange
65
#else
66
    #define _ALS_OnPlayerStateChange
67
#endif
68
69
#define OnGameModeInit ModeInit
70
#define OnPlayerStateChange StateChange