Just a help if someone can help
#1

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
Reply
#2

anyone?
Reply
#3

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;
}
Reply
#4

nope didnt get it
Reply
#5

Quote:
Originally Posted by Domnic Toretto
Посмотреть сообщение
nope didnt get it
LOLZ
Reply
#6

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.
Reply
#7

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
Reply
#8

bumpy
Reply
#9

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));
}
Reply
#10

Thanks alot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)