/ramp - 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: /ramp (
/showthread.php?tid=185949)
/ramp -
Mr.Jvxmc - 26.10.2010
Hey,
how i can do this, that player type's /ramp on/off then ramp in enabled and if he/she press CTRL & appears to him a ramp plz help!
Re: /ramp -
Miguel - 27.10.2010
It's bit complicated...
First, you check if the player is pressing CTRL, if it is then create an object in front of the player. After creating this object, set a timer to destroy it.
pawn Код:
new GlobalVarForObject[MAX_PLAYERS]; // this is a global variable to store object's ID
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & CTRL_KEY_HERE) // you've gotta change it by yourself
{
DestroyObject(GlobalVarForObject[playerid]); // if there's still an object we delete it
GlobalVarForObject[playerid] = CreateObject(/*object params...*/); // replace by object param, just like modelid and coordinates
SetTimerEx("DestroyRamp", TIME_HERE, false, "i", playerid); // TIME_HERE has to be replaced by the time of the ramp in milliseconds
}
return 1;
}
forward DestroyRamp(playerid);
public DestroyRamp(playerid) // this callback destroy our ramp
{
DestroyObject(GlobalVarForObject[playerid]); // we destroy the ramp created by the x playerid
return 1;
}
You'll need GetXYInFrontOfPlayer and the object angle to align it.
Re: /ramp -
(SF)Noobanatior - 27.10.2010
i've done this umm hold on .....
Код:
#if defined _ramp_included
#endinput
#endif
#define _ramp_included
#pragma library ramp
static Pressedkey[MAX_PLAYERS] = {false, ...};
new jumped[MAX_PLAYERS] = {-1, ...};
static ramped[MAX_PLAYERS];
static noramp[MAX_PLAYERS];
forward Keys();
forward DeleteRamp(playerid);
forward RampCommandText(playerid, cmdtext[]);
public RampCommandText(playerid, cmdtext[]){
if (strcmp("/ramphelp ", cmdtext, true, 9) == 0) {
SendClientMessage(playerid, COLOUR_GOOD, "Type /rampon to turn ramp spawning on.");
SendClientMessage(playerid, COLOUR_GOOD, "Type /rampoff to turn ramp spawning off.");
SendClientMessage(playerid, COLOUR_GOOD, "Press the [Fire] button whilst in a vehicle to spawn a ramp.");
return 1;
}
if (strcmp("/rampoff ", cmdtext, true, 8) == 0) {
ramped[playerid] = 1;
noramp[playerid] = 1;
SendClientMessage(playerid, COLOUR_BAD, "Type /rampon to turn it back on!");
return 1;
}
if (strcmp("/rampon ", cmdtext, true, 7) == 0) {
ramped[playerid] = 0;
noramp[playerid] = 0;
SendClientMessage(playerid, COLOUR_BAD, "Type /rampoff to turn it back off!");
return 1;
}
return 0;
}
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 && noramp[playerid] == 1) {
if(keys & KEY_FIRE && IsCarRampable(playerid)) {
SendClientMessage(playerid, COLOUR_BAD, "You have Ramping turned off!");
SendClientMessage(playerid, COLOUR_BAD, "Type /rampon to turn it back on!");
}
}
else if(ramped[playerid] == 1) {
}
else if (keys & KEY_FIRE && IsPlayerInCar(playerid)) {{
GetPlayerPos(playerid, x, y, z);
angle = GetPosInFrontOfPlayer(playerid, x, y, GetRampDistance(playerid));
jumped[playerid] = CreateObject(1632, x, y, z - 0.5, 0.0, 0.0, angle);
ramped[playerid] = 1;
SetTimerEx("DeleteRamp", 800, 0, "d", playerid);
}
}
} else Pressedkey[playerid] = false;
}
}
public DeleteRamp(playerid){
if (jumped[playerid] != -1) {
DestroyObject(jumped[playerid]);
jumped[playerid] = -1;
ramped[playerid]=0;
}
}
#endinput
save that as ramp.inc and put it in your .pwn folder same as project
then at the top of ya game go #include "ramp"
then under OnGameModeInit()
Код:
SetTimer("Keys", 100, 1);
then at the bottom of OnPlayerCommandText(playerid, cmdtext[]) just above Return 0; go
Код:
new gcmd;
gcmd += RampCommandText(playerid, cmdtext);
if(gcmd >= 1) return 1;
try that
edit... edit
Re: /ramp -
Mr.Jvxmc - 27.10.2010
nah i don't want a inc
plz more