Vehicleid variable when player leaves -
izeatfishz - 24.12.2015
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?
Re: Vehicleid variable when player leaves -
TwinkiDaBoss - 24.12.2015
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]
Re: Vehicleid variable when player leaves -
izeatfishz - 24.12.2015
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]?
Re: Vehicleid variable when player leaves -
TwinkiDaBoss - 24.12.2015
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;
}
Re: Vehicleid variable when player leaves -
izeatfishz - 24.12.2015
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]?
Re: Vehicleid variable when player leaves -
TwinkiDaBoss - 24.12.2015
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
Thats just a simple example.
Now you create another car
etc. etc. Its hard to explain, do the command and u will see why
Basically our VID = MAX_VEHICLES