Alternative DestroyVehicle();
#1

Hey, I got this problem, I have some car rental system sat up at my server that I scripted self.

I'm creating the cars with "AddStaticVehicle()"

But when people unrent it, I need to make it spawn back at its position. But I got no DestroyVehicle(); that acts like the vehicle would have exploded. Beacuse then it respawns. With DestroyVehicle(); it doesn't.

Is it some kind of way to destroy the vehicle, but let it respawn as it was destroyed normally?
I've tried setting it high up in air and tried to explode it, and even drown it. None of them worked.

>> Solved <<
Reply
#2

set pos in the water (or under the map) than destroy (you wont see the explosion)
Reply
#3

Tried, wont work. It just never exploded or removed in the water
Reply
#4

Why don't you use AddStaticVehicleEx?
Reply
#5

or maybe isplayerconnected?

edit:

not that.

lol something like if(vehicle,unrented blablabla
Reply
#6

You can set the position of the vehicle to somewhere far away first, and then set its health to 0. Takes ~5 secs to explode and another 5 to respawn.
Reply
#7

Quote:
Originally Posted by [DK]JaloNik
Посмотреть сообщение
Why don't you use AddStaticVehicleEx?
I do xD Just didn't said it. It wont make any difference anyway.

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You can set the position of the vehicle to somewhere far away first, and then set its health to 0. Takes ~5 secs to explode and another 5 to respawn.
Tell me a place far away that you could do something like that. There players never are... :P
Reply
#8

for example 0|3333|-10
Should be somewhere in the ocean, 300m north of the coast :P
Reply
#9

That doesnt work, if you didnt get that. The car never explodes. I follow it self.
Reply
#10

RespawnVehicle?
Reply
#11

Quote:
Originally Posted by Blt950
Посмотреть сообщение
I do xD Just didn't said it. It wont make any difference anyway.
If you set the time to be like, 3-5 mn without any player in, it's kinda the same. Will go fast. XD
Reply
#12

Hm, thought it would, tested it sometimes. But maybe it doesnt explode because its streamed out.

Another idea: put it to its spawnpoint "by hand", meaning just set the position. You could also put it together with a repair, but you would need to save its spawn point then (maybe a CreateStaticVehicleExEx and a RespawnVehicle)
Reply
#13

If just samp had a simple function as "RespawnVehicle(vehicleid);" That would solve it xD

EDIT: I just found out that it has it lol! https://sampwiki.blast.hk/wiki/SetVehicleToRespawn

Gotta check it out :3
Reply
#14

Oops xD

Hm, just thought there would be such a command for players only
Reply
#15

Indeed I thought that too..
The command just worked 100%, it even fixes the vehicle and all stuff

They should add this command under "Related Functions" at the wiki. Then I would have found it ages ago xD

Edit: Also made a little edit on the wiki now https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle shows a related link to https://sampwiki.blast.hk/wiki/SetVehicleToRespawn

And even a little extra example of use
Reply
#16

What about this:
pawn Код:
if(strcmp(cmd, "/unrentcar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(HireCar[playerid] != 299)
            {
                if(idcar == HireCar[playerid])
                {
                    TogglePlayerControllable(playerid, 1);
                }
                SetVehicleToRespawn(HireCar[playerid]);
                HireCar[playerid] = 299;
                GameTextForPlayer(playerid, "~w~You no longer rent a car", 5000, 3);
            }
        }
        return 1;
    }
It fits into my system + works perfectly. :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)