/ramp problem
#1

I have a simple command:
pawn Код:
if(strcmp(cmd, "/ramp", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            SetPlayerColor(playerid,COLOR_WHITE);
            new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "UTILIZEAZA: /ramp (down sau up)");
                return 1;
            }
            {
                new rampup = GetPVarInt(playerid, "RampUp");
                new rampdn = GetPVarInt(playerid, "RampDown");
                new carid = GetPlayerVehicleID(playerid);
                //new mm = GetVehicleModel(carid);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                if(IsADFT(carid))
                {
                    if(strcmp(x_nr,"up",true) == 0)
                    {
                        if(IsValidObject(rampdn))
                        {
                            DestroyObject(rampdn);
                            SetPVarInt(playerid, "RampDown", 0);
                        }
                        if(!IsValidObject(rampup))
                        {
                            rampup = CreateObject(18756,0,0,-1000,0,0,0,100);
                            SetPVarInt(playerid, "RampUp", rampup);
                        }
                        AttachObjectToVehicle(rampup, carid, 0.524999,-2.700001,1.650000,-269.999877,0.000000,89.099983);
                        format(string, sizeof(string), "* %s a ridicat rampa.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        return 1;
                    }
                    else if(strcmp(x_nr,"down",true) == 0)
                    {
                        if(IsValidObject(rampup))
                        {
                            DestroyObject(rampup);
                            SetPVarInt(playerid, "RampUp", 0);
                        }
                        if(!IsValidObject(rampdn))
                        {
                            rampdn = CreateObject(18756,0,0,-1000,0,0,0,100);
                            SetPVarInt(playerid, "RampDown", rampdn);
                        }
                        AttachObjectToVehicle(rampdn, carid, 0.450000,-8.324991,0.075000,-35.100002,269.999877,178.199890);
                        format(string, sizeof(string), "* %s a lasat rampa.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        return 1;
                    }
                }
            }
        }
    }
if i use /ramp up or /ramp down and relog, the created object is still there.
How i can do when the player use these commands and quit/relog, the rampobject created by him to be destroyed>
Reply
#2

OnPlayerDisconnect

destroy the object
Reply
#3

Erros:
pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(4886) : error 001: expected token: ")", but found "{"
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(4887) : error 017: undefined symbol "rampup"
Lines:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid)
    if(IsADFT(vehicleid)
    {
    DestroyObject(rampup);

    }
Reply
#4

Wrong
Reply
#5

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid)
    if(IsADFT(vehicleid))
    {
    DestroyObject(rampup);

    }
you missed a closing brace,

the other thing is you store rampup inside a pvar,
so youll need to use GetPVarInt
to get the object id to destroy
Reply
#6

Errors:
pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(4887) : error 017: undefined symbol "rampup"
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(4888) : error 017: undefined symbol "rampdn"
Lines:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid)
    if(IsADFT(vehicleid))
    {
    DestroyObject(rampup);
    DestroyObject(rampdn);
    }
Reply
#7

pawn Код:
new rampup = GetPVarInt(playerid, "RampUp");
new rampdn = GetPVarInt(playerid, "RampDown");
new vehicleid = GetPlayerVehicleID(playerid)
    if(IsADFT(vehicleid))
    {
    DestroyObject(rampup);
    DestroyObject(rampdn);
    }
Reply
#8

I have to restart the gamemode to remove the objects,is not working
Reply
#9

you put that code in the callback
OnPlayerDisconnect()?


EDIT:
actually after looking at the code again this would only work if the player was in a vehicle

change the if statement to check if the PVar > 0
if so delete, no matter what the vehicle is.


pawn Код:
new rampup = GetPVarInt(playerid, "RampUp");
new rampdn = GetPVarInt(playerid, "RampDown");
if(rampup) DestroyObject(rampup);
if(rampdn) DestroyObject(rampdn);
Reply
#10

Yes,i did
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)