[TUT]How to make RC vehicles Enterable! -
Deat_Itself - 13.12.2009
[Tutorial]How to make RC vehicles enterable
As I have seen in many topics that many SAMP players asking about how to enter in RC vehicles or when they enter so how to get out from it .So i thought to make a tutorial for them .Thats a simple tutorial which you can use into your Filterscript or Gamemode.
Код:
#include <a_samp>//its already present in every FS
#pragma tabsize 0//if it is not present in the script so it may give you "loose indentation." or if your scripting is in correct sequence so no need to add it
now the car you want to enter,we have to define them .
Код:
#define RC_BANDIT 441
#define RC_BARON 464
#define RC_GOBLIN 501
#define RC_RAIDER 465
#define D_TRAM 449
#define RC_MINITANK 564
#define RC_CAM 594
So now we are ready to start our script .
First we want to know that on which key the player will enter in the vehicle . You can change it to your own choice.
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SECONDARY_ATTACK ){//the secondary attack key ,which you can change into your own choice
if(!IsPlayerInAnyVehicle(playerid)){ //checks the player if he/she is in the vehicle.
new Float:x, Float:y, Float:z, vehicle; //these Float gets the player position that where the player is present
GetPlayerPos(playerid, x, y, z );//gets player position
GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);//gets the player distance from the vehicle
if(IsVehicleRc(vehicle)){ //it checks the player vehicle is RC or not .
PutPlayerInVehicle(playerid, vehicle, 0);
}
}
else {
new vehicleID = GetPlayerVehicleID(playerid);
if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
if(GetVehicleModel(vehicleID) != D_TRAM){
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x+0.5, y, z+1.0);
}
}
}
}
}
Код:
GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &veh){//It should be in script other wise the GetVehicleWithInDistance will not work
for(new i = 1; i < MAX_VEHICLES; i++){
if(GetVehicleModel(i) > 0){
if(GetPlayerVehicleID(playerid) != i ){
new Float:x, Float:y, Float:z;
new Float:x2, Float:y2, Float:z2;
GetVehiclePos(i, x, y, z);
x2 = x1 - x; y2 = y1 - y; z2 = z1 - z;
new Float:vDist = (x2*x2+y2*y2+z2*z2);
if( vDist < dist){
veh = i;
dist = vDist;
}
}
}
}
}
Код:
IsVehicleRc( vehicleid ){//defines the RC vehicles.
new model = GetVehicleModel(vehicleid);
switch(model){
case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_MINITANK: return 1;
default: return 0;
}
return 0;
}
Is that hard ? Not Really.
Saif
Re: [TUT]How to make RC vehicles Enterable! -
Tigerbeast11 - 13.12.2009
nice work!
Re: [TUT]How to make RC vehicles Enterable! -
Deat_Itself - 13.12.2009
thanks
Re: [TUT]How to make RC vehicles Enterable! -
_Sami_ - 13.12.2009
nice Tutorial Saif. it helped me much
Re: [TUT]How to make RC vehicles Enterable! -
Deat_Itself - 13.12.2009
thanks Sami
Re: [TUT]How to make RC vehicles Enterable! -
Doppeyy - 13.12.2009
Nice tut

keep up the good work.
/Artix
Re: [TUT]How to make RC vehicles Enterable! -
GforceNL - 13.12.2009
Nice Tutorial!
Re: [TUT]How to make RC vehicles Enterable! -
LarzI - 13.12.2009
Good job with this tutorial!
The indentation could be better, but that's my opinion, lol :P
7/10 (Y)
Re: [TUT]How to make RC vehicles Enterable! -
MB@ - 13.12.2009
Nice tutorial
Re: [TUT]How to make RC vehicles Enterable! -
CrunkBankS - 13.12.2009
Big thanks