SHOW:
|
|
- or go back to the newest paste.
1 | new Speedlimit[MAX_PLAYERS]; | |
2 | //Under OnGameModeInIt | |
3 | ManualVehicleEngineAndLights(); | |
4 | //======================================Stocks=======================================// | |
5 | ||
6 | //Vehicle speed | |
7 | stock GetVehicleSpeed(vehicleid, get3d) | |
8 | { | |
9 | new Float:x, Float:y, Float:z; | |
10 | GetVehicleVelocity(vehicleid, x, y, z); | |
11 | return SpeedCheck(x, y, z, 100.0, get3d); | |
12 | } | |
13 | stock ModifyVehicleSpeed(vehicleid,mph) //Miles Per Hour | |
14 | { | |
15 | new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple; | |
16 | GetVehicleVelocity(vehicleid,Vx,Vy,Vz); | |
17 | DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz); | |
18 | if(DV > 0) //Directional velocity must be greater than 0 (display strobes if 0) | |
19 | { | |
20 | multiple = ((mph + DV * 100) / (DV * 100)); //Multiplying DV by 100 calculates speed in MPH | |
21 | return SetVehicleVelocity(vehicleid,Vx*multiple,Vy*multiple,Vz*multiple); | |
22 | } | |
23 | return 0; | |
24 | } | |
25 | //================================================Commands=============================================// | |
26 | ||
27 | //------------------------------Vehicle commands------------------------------// | |
28 | CMD:speed(playerid, params[]) | |
29 | { | |
30 | new string[128], speed; | |
31 | if(sscanf(params, "i", speed)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE] /speed (MPH)"); | |
32 | if(speed < 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] invalid MPH speed."); | |
33 | Speedlimit[playerid] = speed; | |
34 | if(speed == 0) format(string, sizeof(string), "[VEHICLE] You have turned your speed limit off.", speed); | |
35 | else format(string, sizeof(string), "[VEHICLE] You have set your speed limit to %d MPH.", speed); | |
36 | SendClientMessage(playerid, COLOR_YELLOW, string); | |
37 | return 1; | |
38 | } | |
39 | ||
40 | CMD:engine(playerid, params[]) | |
41 | { | |
42 | #pragma unused params | |
43 | new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective; | |
44 | vehicleid = GetPlayerVehicleID(playerid); | |
45 | GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); | |
46 | if(!IsPlayerInAnyVehicle(playerid)) | |
47 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command."); | |
48 | if(GetPlayerVehicleSeat(playerid) != 0) | |
49 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command."); | |
50 | - | if(vehicleid != BC1 && vehicleid != BC2 && vehicleid != BC3 && vehicleid != BC4 && vehicleid != BC5 && vehicleid != BC6) |
50 | + | |
51 | - | { |
51 | + | |
52 | SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective); | |
53 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine shut off."); | |
54 | } | |
55 | else | |
56 | { | |
57 | SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective); | |
58 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Engine started."); | |
59 | } | |
60 | return 1; | |
61 | } | |
62 | ||
63 | CMD:lights(playerid, params[]) | |
64 | { | |
65 | #pragma unused params | |
66 | new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective; | |
67 | vehicleid = GetPlayerVehicleID(playerid); | |
68 | GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); | |
69 | if(!IsPlayerInAnyVehicle(playerid)) | |
70 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command."); | |
71 | if(GetPlayerVehicleSeat(playerid) != 0) | |
72 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command."); | |
73 | if(lights == 1) | |
74 | { | |
75 | SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective); | |
76 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] lights turned off."); | |
77 | } | |
78 | else | |
79 | { | |
80 | SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective); | |
81 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] lights turned on."); | |
82 | } | |
83 | return 1; | |
84 | } | |
85 | ||
86 | CMD:bonnet(playerid, params[]) | |
87 | { | |
88 | #pragma unused params | |
89 | new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective; | |
90 | vehicleid = GetPlayerVehicleID(playerid); | |
91 | GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); | |
92 | if(!IsPlayerInAnyVehicle(playerid)) | |
93 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command."); | |
94 | if(GetPlayerVehicleSeat(playerid) != 0) | |
95 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command."); | |
96 | if(bonnet == 1) | |
97 | { | |
98 | SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,0,boot,objective); | |
99 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Bonnet closed."); | |
100 | } | |
101 | else | |
102 | { | |
103 | SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,1,boot,objective); | |
104 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Bonnet opened."); | |
105 | } | |
106 | return 1; | |
107 | } | |
108 | ||
109 | CMD:boot(playerid, params[]) | |
110 | { | |
111 | #pragma unused params | |
112 | new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective; | |
113 | vehicleid = GetPlayerVehicleID(playerid); | |
114 | GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); | |
115 | if(!IsPlayerInAnyVehicle(playerid)) | |
116 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in a vehicle in order to use this command."); | |
117 | if(GetPlayerVehicleSeat(playerid) != 0) | |
118 | return SendClientMessage(playerid, COLOR_RED, "[ERROR] You must be in the driver seat in order to use this command."); | |
119 | if(boot == 1) | |
120 | { | |
121 | SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective); | |
122 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Boot closed."); | |
123 | } | |
124 | else | |
125 | { | |
126 | SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective); | |
127 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Boot opened."); | |
128 | } | |
129 | return 1; | |
130 | } | |
131 | ||
132 | CMD:lock(playerid, params[]) | |
133 | { | |
134 | #pragma unused params | |
135 | if(IsPlayerInAnyVehicle(playerid)) | |
136 | { | |
137 | new State=GetPlayerState(playerid); | |
138 | if(State!=PLAYER_STATE_DRIVER) | |
139 | { | |
140 | SendClientMessage(playerid,COLOR_RED,"[ERROR] You must be in the driver's seat in order to use this command."); | |
141 | return 1; | |
142 | } | |
143 | new i; | |
144 | for(i=0;i<MAX_PLAYERS;i++) | |
145 | { | |
146 | if(i != playerid) | |
147 | { | |
148 | SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1); | |
149 | } | |
150 | } | |
151 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Vehicle locked."); | |
152 | new Float:pX, Float:pY, Float:pZ; | |
153 | GetPlayerPos(playerid,pX,pY,pZ); | |
154 | PlayerPlaySound(playerid,1056,pX,pY,pZ); | |
155 | } | |
156 | else | |
157 | { | |
158 | SendClientMessage(playerid, COLOR_RED,"[ERROR] You must be in a vehicle in order to use this command."); | |
159 | } | |
160 | return 1; | |
161 | } | |
162 | ||
163 | CMD:unlock(playerid, params[]) | |
164 | { | |
165 | #pragma unused params | |
166 | if(IsPlayerInAnyVehicle(playerid)) | |
167 | { | |
168 | new State=GetPlayerState(playerid); | |
169 | if(State!=PLAYER_STATE_DRIVER) | |
170 | { | |
171 | SendClientMessage(playerid,COLOR_RED,"[ERROR] You must be in the driver's seat in order to use this command."); | |
172 | return 1; | |
173 | } | |
174 | new i; | |
175 | for(i=0;i<MAX_PLAYERS;i++) | |
176 | { | |
177 | SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0); | |
178 | } | |
179 | SendClientMessage(playerid, COLOR_YELLOW, "[VEHICLE] Vehicle unlocked."); | |
180 | new Float:pX, Float:pY, Float:pZ; | |
181 | GetPlayerPos(playerid,pX,pY,pZ); | |
182 | PlayerPlaySound(playerid,1057,pX,pY,pZ); | |
183 | } | |
184 | else | |
185 | { | |
186 | SendClientMessage(playerid, COLOR_RED,"[ERROR] You must be in a vehicle in order to use this command."); | |
187 | } | |
188 | return 1; | |
189 | } | |
190 | ///====================================================================================/// | |
191 | //Under ONPlayerUpdate | |
192 | ||
193 | if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Speedlimit[playerid]) | |
194 | { | |
195 | new a, b, c; | |
196 | GetPlayerKeys(playerid, a, b ,c); | |
197 | if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > Speedlimit[playerid]) | |
198 | { | |
199 | new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - Speedlimit[playerid]; | |
200 | ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed); | |
201 | } | |
202 | } | |
203 | ||
204 | //Thank you |