Vehicle Problem
#1

I know I'm not the only one who has this problem.
I'm the owner of a stunting server, and I have a big problem.

For example, ID 0 types /v NRG. So a NRG-500 spawns...
I allocate the vehicleid to a per player variable
Lets say that NRG is vehicleid 200.
So that means there are 200 vehicles in the server.

Now ID 1 types /v infernus. So an infernus spawns.
So now I will again allocate the vehicle id to a per player variable.
This infernus will be vehicleid 201.
Now we have 201 vehicles in the server.

Now the NRG of ID 0 gets destroyed, and I delete the vehicle for ever.
So now we have 200 vehicles in the server.

ID 3 types /v turismo.
And again I will allocate the vehicleid to the per player variable.
So now there are 201 vehicles in the server and ID's 3 per player variable will be 201.

So now ID 1 and ID 3 have the same vehicleid in the per player variable...

If I do DestroyVehicle(PlayerCar[3]) <- Destroying vehicle ID 201, thats allocated from playerid 3.
It will destroy the vehicle from playerid 1.

I don't know how to fix this!
I know the problem, as explained, but I have no idea on how to fix it. (actually I do, do a loop)
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=348235
A simple ****** search found that topic. Also this might be the source of my problems with vehicles too. Gotta check into that!
Reply
#3

Doesn't CreateVehicle return the ID of the vehicle created? I tested this last time, I created 10 vehicles and desroyed ID 5 then create a new vehicle, it'll fill in the slot and return 5. So as long as you don't use a seperate variable to know the vehicle ID you'll be fine? Or am I misunderstanding you.
Reply
#4

You're mistaking the vehicle ID that CreateVehicle returns with the amount of vehicles created, like playbox already pointed out, sort of.
Reply
#5

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
You're mistaking the vehicle ID that CreateVehicle returns with the amount of vehicles created, like playbox already pointed out, sort of.
But I know something is messing up the vehicle ids...
Reply
#6

Well, you said you store it in a player variable? What do you store the ID CreateVehicle returns or a variable you manually keep track of?
Reply
#7

buffer overflow OR your not initing / resetting your variables properly. This isn't really discussion, it's more of scripting help, this problem is the same as the textdraw problem, 3DText label problem, it's all the SAME issue.
Reply
#8

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Doesn't CreateVehicle return the ID of the vehicle created? I tested this last time, I created 10 vehicles and desroyed ID 5 then create a new vehicle, it'll fill in the slot and return 5. So as long as you don't use a seperate variable to know the vehicle ID you'll be fine? Or am I misunderstanding you.
SAMP WIKI:

Returns The ID of the vehicle created.
https://sampwiki.blast.hk/wiki/CreateVehicle

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Well, you said you store it in a player variable? What do you store the ID CreateVehicle returns or a variable you manually keep track of?
I do something like this:
pawn Код:
gVeh[playerid] = CreateVehicle...
So it returns the vehicle ID.
Like that, if he tries to spam /v to flood the server, it deletes the previous vehicle...
But sometimes it deletes other players vehicles.
Hence why I posted this topic, and I think the problem is what I posted..
Reply
#9

Kar is right, you should have posted this instead in the general scripting help section..
Quote:
Originally Posted by FireCat
Посмотреть сообщение
I do something like this:
pawn Код:
gVeh[playerid] = CreateVehicle...
Now for that specific bit of code you posted, I already linked to a topic with a possible solution;
make sure you reset gVeh[playerid] to 0 every time you destroy a vehicle and there should be no vehicle ID's mixup.
Reply
#10

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Well, you said you store it in a player variable? What do you store the ID CreateVehicle returns or a variable you manually keep track of?
Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
Kar is right, you should have posted this instead in the general scripting help section..

Now for that specific bit of code you posted, I already linked to a topic with a possible solution;
make sure you reset gVeh[playerid] to 0 every time you destroy a vehicle and there should be no vehicle ID's mixup.
I do... Read the topic and you'll understand what I'm trying to say
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)