ramping bugged
#1

hi everybody
i have a bug
the bug is in the angle when i type CTRL then the object will create but its angle is towards right .Its only happens with the road ids for e.g 17639 changes its angle but ramp doesnt, could someone help me please and yes i want that when player press CTRL again and again so his previous object gets remove and the new object will create



Код:
#include <a_samp>
#define red 0xFF0000AA

new Pressedkey[MAX_PLAYERS] = {false, ...};
new jumped[MAX_PLAYERS] = {-1, ...};
new ramped[MAX_PLAYERS];
forward Keys();
forward DeleteRamp(playerid);
forward Float:GetRampDistance(playerid);
forward Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);

public OnFilterScriptInit()
{
	SetTimer("Keys", 100, 1);
	return 1;
}

public Keys()
{
	new keys, jump, updown, playerid;
	new Float:x, Float:y, Float:z, Float:angle;
	for (playerid = 0; playerid < MAX_PLAYERS; playerid++) {
	  if (IsPlayerConnected(playerid)) {
			GetPlayerKeys(playerid, keys, jump, updown);
			if(ramped[playerid] == 1)
			{
			
			}
			else if (keys & KEY_FIRE && IsPlayerInAnyVehicle(playerid)) {{
					  GetPlayerPos(playerid, x, y, z);
					  angle = GetPosInFrontOfPlayer(playerid, x, y, GetRampDistance(playerid));
					  jumped[playerid] = CreateObject(17639, x, y, z - 0.5, 0.0, 0.0, angle);
					  ramped[playerid] = 1;
					  SetTimerEx("DeleteRamp", 1000, 0, "d", playerid);
				  }
			  }
			} else Pressedkey[playerid] = false;
		}
}

public DeleteRamp(playerid)
{
	if (jumped[playerid] != -1) {
	  DestroyObject(jumped[playerid]);
	  jumped[playerid] = -1;
	  ramped[playerid]=0;
	}
}

public OnFilterScriptExit()
{
	for (new i=0; i<MAX_PLAYERS; i++)
	{
		if (jumped[i] != -1) DestroyObject(jumped[i]);
	}
}

Float:GetRampDistance(playerid)
{
	new ping = GetPlayerPing(playerid), Float:dist;
	dist = floatpower(ping, 0.25);
	dist = dist*4.0;
	dist = dist+5.0;
	return dist;
}

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

public OnPlayerExitVehicle(playerid, vehicleid)
{
	for (new i=0; i<MAX_PLAYERS; i++)
	{
		if (jumped[i] != -1) DestroyObject(jumped[i]);
	}
}
Reply
#2

Take an example of this. I made this months before:
Код:
#include <a_samp>

new bool:CreatedRamp[MAX_PLAYERS];
new Ramp;

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Ramp Spawning by [WsR]RyDeR - Loaded -");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	new i = 0;
	while(i < MAX_PLAYERS)
	{
		CreatedRamp[i] = false;
		DestroyPlayerObject(i, Ramp);
		i++;
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(CreatedRamp[playerid] == true) DestroyPlayerObject(playerid, Ramp), CreatedRamp[playerid] = false;
	CreatedRamp[playerid] = false;
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (IsPlayerInAnyVehicle(playerid))
	{
		if(newkeys == KEY_FIRE)
		{
		  if(CreatedRamp[playerid] == true) DestroyPlayerObject(playerid, Ramp), CreatedRamp[playerid] = false;
			new Float:pX,Float:pY,Float:pZ,Float:vA, Arabam = GetPlayerVehicleID(playerid);
			GetVehiclePos(Arabam, pX, pY, pZ);
			GetVehicleZAngle(Arabam, vA);
			Ramp = CreatePlayerObject(playerid, 1632, pX + (20.0 * floatsin(-vA, degrees)), pY + (20.0 * floatcos(-vA, degrees)), pZ, 0, 0, vA);
			CreatedRamp[playerid] = true;
		}
	}
	return 1;
}
Reply
#3

Quote:
Originally Posted by [WsR
RyDeR ]
Take an example of this. I made this months before:
Код:
#include <a_samp>

new bool:CreatedRamp[MAX_PLAYERS];
new Ramp;

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Ramp Spawning by [WsR]RyDeR - Loaded -");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	new i = 0;
	while(i < MAX_PLAYERS)
	{
		CreatedRamp[i] = false;
		DestroyPlayerObject(i, Ramp);
		i++;
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(CreatedRamp[playerid] == true) DestroyPlayerObject(playerid, Ramp), CreatedRamp[playerid] = false;
	CreatedRamp[playerid] = false;
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (IsPlayerInAnyVehicle(playerid))
	{
		if(newkeys == KEY_FIRE)
		{
		  if(CreatedRamp[playerid] == true) DestroyPlayerObject(playerid, Ramp), CreatedRamp[playerid] = false;
			new Float:pX,Float:pY,Float:pZ,Float:vA, Arabam = GetPlayerVehicleID(playerid);
			GetVehiclePos(Arabam, pX, pY, pZ);
			GetVehicleZAngle(Arabam, vA);
			Ramp = CreatePlayerObject(playerid, 1632, pX + (20.0 * floatsin(-vA, degrees)), pY + (20.0 * floatcos(-vA, degrees)), pZ, 0, 0, vA);
			CreatedRamp[playerid] = true;
		}
	}
	return 1;
}
mine is same as you when if it is ramp but when i enter the id of the road so the road is towards right side like this __<road shape i want it like that | my road shape
| <my car shape | my shape

hope so you can.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)