Car won't despawn
#1

Well, for some weird reason when I type vehicle ID it won't respawn :/

pawn Code:
if(strcmp(cmdtext, "/avdespawn", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 3 || IsPlayerAdmin(playerid))
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    if(IsPlayerInAnyVehicle(playerid))
                    {
                        new currentvehid;
                        currentvehid = GetPlayerVehicleID(playerid);
                        DestroyVehicle(currentvehid);
                        TogglePlayerControllable(playerid,1);
                        return 1;
                    }
                    else SendClientMessage(playerid,COLOR_ORANGE,"[ERROR:] You're not in a vehicle.");
                }
                if(strval(tmp) == INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Invalid vehicle ID.");
                DestroyVehicle(strval(tmp));
                return 1;
            }
            else SendClientMessage(playerid,COLOR_ORANGE,"[ERROR:] Either you're not an administrator, or you don't have the privileges to use this command.");
        }
        return 1;
    }
Reply
#2

NOT DestroyVehicle(currentvehid);

Replace it with SetVehicleToRespawn(currentvehid);
Reply
#3

No, I need to destroy it. The part when you don't type anything works, but if I type the car ID it gives me nothing.
Reply
#4

AHAHAHA. Well, OBVIOUSLY, it will not work. Download sscanf. Otherwise, use this example for help:

https://sampwiki.blast.hk/wiki/OnPlayerPrivmsg
Reply
#5

No need to be a dick.
Reply
#6

Eh? Mate, deal with this. You can do it. Did your mother not teach you to say "please" and "thanks?"
Reply
#7

Quote:
Originally Posted by Grand_Micha
View Post
Eh? Mate, deal with this. You can do it. Did your mother not teach you to say "please" and "thanks?"
Funny how you tell him if his mother told him to say "please" and "thanks" when you never helped him.


Also, it doesn't look like you defined tmp, unless you have it as a global variable. Define it if it isn't

pawn Code:
new tmp[128];
Reply
#8

Grand_Micha I reported your post. I never asked you to help me. Plus you gave me all the wrong answers, I haven't asked on how to respawn a vehicle, I asked why my code for destroying one isn't working.

Kindred thanks, but I made a loop that get's the player's closest vehicle, and then it destroys it. Also, I'll check where I positioned my command, maybe it's before I defined the tmp string.
Reply
#9

Quote:
Originally Posted by Makaveli93
View Post
Well, for some weird reason when I type vehicle ID it won't respawn

That is PRECISELY what you did.
Reply
#10

Sorry, but it's kindda a mess here, are you trying to destroy a vehicle that you type it id, or a one that you are in?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)