Vehicleid variable when player leaves
#1

Hi, i don't ask here much but I'm mind boggled on this question..

When the player spawns his vehicle it assigns Vehicle[playerid] = createvehicle...

However I don't want to destroy the variable when the player leaves because then the vehicle would be destroyed and I couldn't make systems like breaking in scripts because the vehicleid isn't linked with the owner playerid..

But I don't want to destroy the variable and vehicle when the player leaves because if they crashed people in their car would destroy and would reset to the spawn point..

Fixes?
Reply
#2

Why dont you link it to Vehicle ID instead?

Ie:
When you create a vehicle, store it inside
2 variables

PHP код:
new Car[MAX_VEHICLES]; //assign the car into some ID 
And then after the car is created, assign the car to the player
PHP код:
MyCar[playerid] = Car[vehicleid]; 
So now when you enter a car, you can check if MyCar[playerid] matched Car[vehicleid]
Reply
#3

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Why dont you link it to Vehicle ID instead?

Ie:
When you create a vehicle, store it inside
2 variables

PHP код:
new Car[MAX_VEHICLES]; //assign the car into some ID 
And then after the car is created, assign the car to the player
PHP код:
MyCar[playerid] = Car[vehicleid]; 
So now when you enter a car, you can check if MyCar[playerid] matched Car[vehicleid]
Hmm, I've been up 24 hours so sorryif I'm playing up here but, my spawning command is something like this:

Код:
Vehicle[playerid] = CreateVehicle(VehicleInfo[playerid][vModel], VehicleInfo[playerid][vX],VehicleInfo[playerid][vY],VehicleInfo[playerid][vZ],VehicleInfo[playerid][vAngle],VehicleInfo[playerid][vColor1],VehicleInfo[playerid][vColor2],60 * 1000000);
	
Vehicle[playerid] = Car[vehicleid];
And I'd get a undefined symbol "vehicleid".. so uhh.

And if they leave, i reset the variable vehicle[playerid] so then when they rejoin how would i connect Car[vehicleid] to the new Vehicle[playerid]?
Reply
#4

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Hmm, I've been up 24 hours so sorryif I'm playing up here but, my spawning command is something like this:

Код:
Vehicle[playerid] = CreateVehicle(VehicleInfo[playerid][vModel], VehicleInfo[playerid][vX],VehicleInfo[playerid][vY],VehicleInfo[playerid][vZ],VehicleInfo[playerid][vAngle],VehicleInfo[playerid][vColor1],VehicleInfo[playerid][vColor2],60 * 1000000);
	
Vehicle[playerid] = Car[vehicleid];
And I'd get a undefined symbol "vehicleid".. so uhh.
Well simple.
PHP код:
CMD:createcar(playerid,params[]) {
    new 
vid CreateVehicle(bla bla bla);
    
Car[vid ] = vid ;
    return 
true;

Reply
#5

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Well simple.
PHP код:
CMD:createcar(playerid,params[]) {
    new 
vid CreateVehicle(bla bla bla);
    
Car[vid ] = vid ;
    return 
true;

And if they leave, i reset the variable vehicle[playerid] so then when they rejoin how would i connect Car[vehicleid] to the new Vehicle[playerid]?
Reply
#6

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Yeah but what's the point of making 'new vid' when I've already created new Car[max_vehicles] for the purpose of linking the new car to a vehicleid..
Do this
PHP код:
new Car[MAX_VEHICLES];
CMD:createcar(playerid,params[]) {
    new 
vid CreateVehicle(450,0,0,0,0,0,0,0,0);
    
printf("Creating vehicle server ID: %i",vid);
    
Car[vid ] = vid ;
    
printf("Car[vid] = %i",vid);
    return 
true;

Basically vid will represent those MAX_VEHICLES localy.
Meaning, vid = will increase depending on MAX_VEHICLES, meaning there are 0 cars on the server, you type this command, we will create car ID:1, we will store it inside
PHP код:
Car[1] = 1
Thats just a simple example.
Now you create another car
PHP код:
Car[2] = 2
etc. etc. Its hard to explain, do the command and u will see why


Basically our VID = MAX_VEHICLES
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)