Entering Rc vehicles
#1

Код:
public enterrc (playerid,vehicleid)
{
	new Float:vehx, Float:vehy, Float:vehz;
	GetVehiclePos(vehicleid, vehx, vehy, vehz);
	if(IsPlayerInRangeOfPoint(playerid, 5, vehx, vehy, vehz))
	{
		if(GetVehicleModel(vehicleid) == 464 | 465 | 501 | 564 | 594)
		{
			GetPlayerVehicleSeat(playerid);
   			PutPlayerInVehicle(playerid, vehicleid, 0);
			return 1;
		}
		else return 0;
	}
	else return 0;
}
The scriptpiece above is for entering RC vehicles when you hit enter vehicle button..
What did i do wrong?
Here is the other part:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED( KEY_SECONDARY_ATTACK ))
	{
		SetTimer("enterrc",0,0);
	}
}
I dont get errors when i compile, but when i go close to an Rc vehicle and click the enter button nothing happens.
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED( KEY_SECONDARY_ATTACK ))
    {
        new vID = GetPlayerVehicleID(playerid);
                      enterrc(playerid, vID);
    }
}
Not sure if it will work. Due to the fact that you never define which vehicle.
Reply
#3

I dont think you should add like vehicleid's in there

By the way, this script is made for when you get close to some random
Rc vehicle on the map, you can enter it.

No spawned vehicles.
Reply
#4

Bump....
Reply
#5

Do you know any include files that would make this thing easier?
Like an include with functions that detects if you are close to a vehicle or something
Reply
#6

maybe stop triple posting?
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=158074

Try using it that way :P
Reply
#8

Full filter script to enter RC-s, also includes the thingy where you can tow vehicles and shoot with RC tiger, just copy this, paste in pawno and save in Filterscripts folder, later add it to server.cfg:
Код:
#include <a_samp>
#define COLOR_RED 0xFF0000FF
new Float:X,Float:Y,Float:Z;
new PlayerIsInShamal[MAX_PLAYERS],ShamalID[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("\n----------------------------------------");
print(" Vehicles Utilities by zofa    LOADED");
print("----------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
print("\n-----------------------------------------");
print(" Vehicles Utilities by zofa   UNLOADED");
print("-----------------------------------------\n");
return 1;
}

stock IsRCVehicle(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 501,464,441,465,564: return 1;
}
return 0;
}

stock Float:GetXYInFrontOfPlayer(playerid, &Float:xx, &Float:yy, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, xx, yy, a);
if (IsPlayerInAnyVehicle(playerid))
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
else
GetPlayerFacingAngle(playerid, a);
xx += (distance * floatsin(-a, degrees));
yy += (distance * floatcos(-a, degrees));
return a;
}

stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
new Float:px,Float:py,Float:pz;
GetVehiclePos(vehicleid,px,py,pz);
px -= x;
py -= y;
pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
for(new v=0;v<MAX_VEHICLES; v++)
{
GetPlayerPos(playerid,X,Y,Z);
if (newkeys == KEY_FIRE && oldkeys != KEY_FIRE && GetPlayerState(playerid)==PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 525 && IsVehicleInRangeOfPoint(v, 7, X, Y, Z))
{
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
AttachTrailerToVehicle(v,GetPlayerVehicleID(playerid));
}
else
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
}
if (newkeys == KEY_FIRE && oldkeys != KEY_FIRE && GetPlayerState(playerid)==PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 564)
{
GetXYInFrontOfPlayer(playerid, X, Y, 15);
CreateExplosion(X,Y,Z,12,3);
}
if (newkeys == KEY_SECONDARY_ATTACK && oldkeys != KEY_SECONDARY_ATTACK && IsVehicleInRangeOfPoint(v, 2, X, Y, Z) && IsRCVehicle(v))
{
if(!IsPlayerInAnyVehicle(playerid))
{
PutPlayerInVehicle(playerid,v,0);
}
else
{
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,X,Y,Z+0.5);
}
}
if (newkeys == KEY_SECONDARY_ATTACK && oldkeys != KEY_SECONDARY_ATTACK && PlayerIsInShamal[playerid] == 1)
{
GetVehiclePos(ShamalID[playerid], X, Y, Z);
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,X+5,Y+5,Z+1);
SetPlayerInterior(playerid,0);
GivePlayerWeapon(playerid,46,1);
PlayerIsInShamal[playerid] = 0;
}
}
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (ispassenger && GetVehicleModel(vehicleid) == 519)
{
SetPlayerPos(playerid,2.384830,33.103397,1199.849976);
SetPlayerInterior(playerid,1);
PlayerIsInShamal[playerid] = 1;
ShamalID[playerid] = vehicleid;
}
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerIsInShamal[playerid] = 0;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
PlayerIsInShamal[playerid] = 0;
return 1;
}

public OnVehicleDeath(vehicleid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetVehicleModel(vehicleid) == 519 && PlayerIsInShamal[i] == 1)
{
SetPlayerHealth(i, 0);
SendClientMessage(i, COLOR_RED, ">>> The plane has been destroyed.");
PlayerIsInShamal[i] = 0;
}
}
return 1;
}

//End Of File
Reply
#9

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Thanks i got it to work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)