OnPlayerEnterVehicle -
DokerJr - 18.02.2011
Hello.
Please help me with one little script.
I want that if someone gets into a car and that is
CreateVehicle
Let's say that the car is spawned..
Eg: This vehicle is spawned by one admin
But it might be just the vehicles that are created with CreateVehicle
Re: OnPlayerEnterVehicle -
OKStyle - 19.02.2011
In
top of a script:
In
command of create vehicle:
pawn Код:
admincar = CreateVehicle.....
In
OnPlayerEnterVehicle:
pawn Код:
if(vehicleid == admincar)
{
// do smth
}
Re: OnPlayerEnterVehicle -
DokerJr - 19.02.2011
This function it's work only for one car
I want to be for all cars that are spawned
Re: OnPlayerEnterVehicle -
PowerPC603 - 19.02.2011
pawn Код:
// Create an array that can hold up to 2000 vehicles (samp limit), put this at the top of the script
new StaticVehicles[2000];
// Use this to create a vehicle during OnGameModeInit:
Vehicle_AddStatic(VehicleModel, x, y, z, rotation, color1, color2, spawndelay);
// Example:
Vehicle_AddStatic(462, -475.0, -523.0, 26.0, 90.0, -1, -1, 600);
// The function:
Vehicle_AddStatic(vModel, Float:vX, Float:vY, Float:vZ, Float:vRotation, vC1, vC2, vSpawnDelay)
{
// Create a new static vehicle during GameModeInit
new vid = AddStaticVehicleEx(vModel, vX, vY, vZ, vRotation, vC1, vC2, vSpawnDelay);
// Set this vehicle as a static vehicle
StaticVehicles[vid] = 1;
return vid;
}
// In OnPlayerEnterVehicle:
if (StaticVehicles[vehicleid] == 0) // Check if this isn't a static vehicle
SendClientMessage(playerid, 0xFFFFFFFF, "You entered an admin car");
The array StaticVehicles will hold "1" for every static vehicle you created during OnGameModeInit.
When an admin spawns a vehicle later with CreateVehicle, the array holds 0 for that vehicle-id, as you didn't use the "Vehicle_AddStatic" function to create the vehicle.
Re: OnPlayerEnterVehicle -
Vince - 19.02.2011
Too much hassle, and one too large array. This will be much more resource efficient:
pawn Код:
// Top
new
MaxStaticVehicles = 0;
// GamemodeInit
MaxStaticVehicles = AddStaticVehicle(...) // this will be the very LAST STATIC VEHICLE
// Anywhere
stock IsStaticVehicle(vehicleid)
return (vehicleid <= MaxStaticVehicles) ? true : false;
Re: OnPlayerEnterVehicle -
DokerJr - 20.02.2011
No no!
Only vehicles that are created with a command.
Re: OnPlayerEnterVehicle - rjjj - 20.02.2011
Put in the top of your gamemode:
pawn Код:
new CreatedVehicleVar[MAX_PLAYERS];
And, in your command:
pawn Код:
CreatedVehicleVar[playerid] = CreateVehicle....
Finally:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new x = 0; x < 500; x++)
{
if(vehicleid == CreatedVehicleVar[x])
{
//"Let's say that the car is spawned.." ;D
}
}
return 1;
}
I hope that i have helped