SA-MP Forums Archive
RC Vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: RC Vehicle (/showthread.php?tid=199514)



RC Vehicle - buzifej - 15.12.2010

How can I get in and out of a rc vehicle?


Re: RC Vehicle - buzifej - 15.12.2010

please write it down because I do not understand


Re: RC Vehicle - Face9000 - 15.12.2010

At the top of the gamemode:

Код:
#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
Copy this after a public. (Ex: copy it under publicOnPlayerCommandText)

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if(newkeys == KEY_ACTION ){
        if(!IsPlayerInAnyVehicle(playerid)){
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z );
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);

            if(IsVehicleRc(vehicle)){
              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){
    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 ){
  new model = GetVehicleModel(vehicleid);
  switch(model){
  case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_MINITANK: return 1;
  default: return 0;
    }
  return 0;
}
Press TAB to enter in the vehicle and right CTRL to exit.


Re: RC Vehicle - olabv - 15.12.2010

nice


Re: RC Vehicle - buzifej - 16.12.2010

Nice Job and thank you