Just a help if someone can help -
ZBits - 23.08.2012
hello guys i need a script its not a big one its just a small on i think
it is when a player press key left ctrl a ramp spawns a few meter away and if he doesn't want to spawn ramp he can simply use /rampoff or /rampon
will be great if anyone helps
Re: Just a help if someone can help -
ZBits - 23.08.2012
anyone?
Re: Just a help if someone can help -
ThePhenix - 23.08.2012
You may learn something here:
pawn Код:
CMD: object (playerid,params[])
{
new ObjID = strval(params), string[128];
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
X += (3 * floatsin(-Ang, degrees));
Y += (3 * floatcos(-Ang, degrees));
CreateObject(ObjID, X, Y, Z, 0.0, 0.0, Ang);
format(string, sizeof(string), "CreateObject(%d, %0.2f, %0.2f, %0.2f, 0.00, 0.00, %0.2f);", ObjID, X, Y, Z, Ang);
return 1;
}
Re: Just a help if someone can help -
ZBits - 23.08.2012
nope didnt get it
Re: Just a help if someone can help -
Team_PRO - 23.08.2012
Quote:
Originally Posted by Domnic Toretto
nope didnt get it
|
LOLZ
Re: Just a help if someone can help -
clarencecuzz - 23.08.2012
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
new RampActivated[MAX_PLAYERS], Ramp[MAX_PLAYERS], RampTimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
RampActivated[playerid] = 0;
Ramp[playerid] = -1;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/rampon", true) == 0)
{
if(RampActivated[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Have Already Activated Ramps. Use {00FF00}/RAMPOFF");
SendClientMessage(playerid, 0x00FF00FF, "You Have Activated Ramps. Press LCTRL To Create A Ramp.");
RampActivated[playerid] = 1;
return 1;
}
if(strcmp(cmdtext, "/rampoff", true) == 0)
{
if(RampActivated[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Have Not Activated Ramps. Use {00FF00}/RAMPON");
SendClientMessage(playerid, 0xFF0000FF, "You Have Deactivated Ramps.");
RampActivated[playerid] = 0;
if(Ramp[playerid] != -1)
{
DestroyObject(Ramp[playerid]);
Ramp[playerid] = -1;
KillTimer(RampTimer[playerid]);
}
return 1;
}
return 0;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(RampActivated[playerid] == 1)
{
if(Ramp[playerid] != -1)
{
DestroyObject(Ramp[playerid]);
KillTimer(RampTimer[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
X += (3 * floatsin(-Ang, degrees));
Y += (3 * floatcos(-Ang, degrees));
Ramp[playerid] = CreateObject(ObjID, X, Y, Z, 0.0, 0.0, Ang); //Replace ObjID with the ramp object ID
RampTimer[playerid] = SetTimerEx("RemoveRamp", 5000, false, "i", playerid);
}
}
}
}
return 1;
}
forward RemoveRamp(playerid);
public RemoveRamp(playerid)
{
DestroyObject(Ramp[playerid]);
Ramp[playerid] = -1;
return 1;
}
NOTE: You MUST change 'ObjID' with the model ID for the ramp.
Re: Just a help if someone can help -
ZBits - 23.08.2012
The code above does work
but it creates a ramp at my left side i want it to be in the middle the object id is 1503
Re: Just a help if someone can help -
ZBits - 23.08.2012
bumpy
Re: Just a help if someone can help -
clarencecuzz - 23.08.2012
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(RampActivated[playerid] == 1)
{
if(Ramp[playerid] != -1)
{
DestroyObject(Ramp[playerid]);
KillTimer(RampTimer[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetXYInFrontOfPlayer(playerid, X, Y, 5);
Ramp[playerid] = CreateObject(1503, X, Y, Z, 0.0, 0.0, Ang); //Replace ObjID with the ramp object ID
RampTimer[playerid] = SetTimerEx("RemoveRamp", 5000, false, "i", playerid);
}
}
}
}
return 1;
}
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Just a help if someone can help -
ZBits - 23.08.2012
Thanks alot