Assigning an ID to a Car - Car spawn on login
#1

Hello. There is an issue with my gamemode i am experiencing,
when a person buy's a vehicle the vehicle ID will be assigned as the latest bought car id + 1.

For example if there are 300 spawned / bought vehicles, the next bought vehicle will have the ID 301.

The problem is that: i want the owned car to be removed as soon as the owner disconnects,
and i want it to spawn when the person logs in, and the problem is that if there are currently 300 spawned cars
and the persons vehicle "ID" is 350 and the person logs in, it gets messed up and the script won't work properly.

Any idea of how i should solve this issue?

Is there a way to assign an ID to the spawned vehicle?
Reply
#2

in short no!
You cannot set the id to any number youd like..
It is auto assigned by the server to use the first free slot.

dont rely on the VehicleID when saving /loading
try going by the vehicle model instead, and save the colors, plate pos of the car.
Reply
#3

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
in short no!
You cannot set the id to any number youd like..
It is auto assigned by the server to use the first free slot.

dont rely on the VehicleID when saving /loading
try going by the vehicle model instead, and save the colors, plate pos of the car.
This is very weird i have seen another server where my vehicle was ID 6000 and i am pretty sure
the server wouldn't have that many vehicles since the limit is 2000.

Quote:

try going by the vehicle model instead, and save the colors, plate pos of the car.

I will try to use that, even thought that my hopes regarding that are very low.

If anyone has any idea of how i should set it up please don't hesitate.


And if i wouldn't rely on vehicle ID, how am i supose to remove the car "onplayerdisconnect"? =\
Reply
#4

that id could be from a database and not from the actual SAMP server code.

meaning in the database the car's id = 6000
and in the code vehicle id = 1234

i dont know any server that shows the vehicle id to you
but I cant think of anyway to assign a vehicle id as they are created by the samp server.
Their is no SetVehicleId function of anykind.
Reply
#5

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
that id could be from a database and not from the actual SAMP server code.

meaning in the database the car's id = 6000
and in the code vehicle id = 1234

i dont know any server that shows the vehicle id to you
but I cant think of anyway to assign a vehicle id as they are created by the samp server.
Their is no SetVehicleId function of anykind.
I don't really have any idea of how i should fix/modify it.

Any sugestion of the changes i should make. I am looking for the ideas because nothing comes up to my mind to fix,
if you could give me any sugestion i would pass it to pawno.
Reply
#6

i did
when you save the users vehicle
save the model, the colors, the plate the position

that's all you need when they log in,
or however you go about giving them their vehicle.
spawn a vehicle with those details.
Reply
#7

the problem is that way i am not able to lock the car. Since it is no longer related to the vehicle ID.
hell what a headache
Reply
#8

just get the id when you create the vehicle
then use it to lock the car.

so when they login or want to spawn their car ,
(wherever you create the vehicle)

then use
pawn Код:
new playervid[MAX_PLAYERS];

playervid[playerid]=CreateVeh
you should have some kinda var to track the vehicle id for the player
that should not be saved, but used when creating/deleting the vehicle


hope this helps.


~J5
Reply
#9

Okay well while i was developing my code i've got the most stupid error ever...

When i put this:
pawn Код:
PlayerInfo[playerid][pC1Locationx] = 0;
                            PlayerInfo[playerid][pC1Locationy] = 0;
                            PlayerInfo[playerid][pC1Locationz] = 0;
                            PlayerInfo[playerid][pC1Angle] = 0;
and i compile, i do not get any error.

But when i change the values:
i get 4 errors : warning 203 Tag mismatch....

What the hell..
pawn Код:
PlayerInfo[playerid][pC1Locationx] = -1589.2644;
                            PlayerInfo[playerid][pC1Locationy] = 106.9119;
                            PlayerInfo[playerid][pC1Locationz] = 3.5495;
                            PlayerInfo[playerid][pC1Angle] = 317.1649;
Reply
#10

make sure your enum is defining these as floats like

pawn Код:
Float:pC1Locationx,
Float:pC1Locationy ,
Float:pC1Locationz,
Float:pC1Angle,
and then they must use float values
pawn Код:
PlayerInfo[playerid][pC1Locationx] = 0.0;
PlayerInfo[playerid][pC1Locationy] = 0.0;
PlayerInfo[playerid][pC1Locationz] = 0.0;
PlayerInfo[playerid][pC1Angle] = 0.0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)