28.02.2011, 19:42
So I tried to make rent cars for my server
I created 3 variables(sorry for my bad einglish)
Now
OnGameModeInIT
Added a public
and a code
And onPlayerEnterVehicle
I created 3 variables(sorry for my bad einglish)
PHP Code:
new rentcar[20];
new newcar;
new rentkey[MAX_PLAYERS];
OnGameModeInIT
PHP Code:
rentcar[0] = AddStaticVehicleEx(510,1560.93286133,-2309.08129883,13.24319458,91.99993896,-1,-1,5); //Mountain Bike
rentcar[1] = AddStaticVehicleEx(510,1560.88171387,-2311.87597656,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[2] = AddStaticVehicleEx(510,1561.00732422,-2315.56152344,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[3] = AddStaticVehicleEx(510,1561.11535645,-2318.67944336,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[4] = AddStaticVehicleEx(510,1561.23120117,-2321.97534180,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[5] = AddStaticVehicleEx(510,1561.34765625,-2325.31958008,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[6] = AddStaticVehicleEx(510,1561.46789551,-2328.74047852,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[7] = AddStaticVehicleEx(510,1561.57324219,-2331.73730469,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[8] = AddStaticVehicleEx(510,1561.69628906,-2335.23388672,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
rentcar[9] = AddStaticVehicleEx(468,-1330.38940430,-284.64837646,13.90843773,0.00000000,-1,-1,15); //Sanchez
rentcar[10] = AddStaticVehicleEx(468,-1331.91455078,-285.06213379,13.90843773,0.00000000,-1,-1,5); //Sanchez
rentcar[11] = AddStaticVehicleEx(462,1305.86437988,1278.80163574,10.49053192,0.00000000,-1,-1,5); //Faggio
rentcar[12] = AddStaticVehicleEx(462,1308.87707520,1278.86083984,10.49053192,0.00000000,-1,-1,5); //Faggio
rentcar[13] = AddStaticVehicleEx(462,1311.88745117,1278.89587402,10.49053192,0.00000000,-1,-1,5); //Faggio
rentcar[14] = AddStaticVehicleEx(462,1314.59558105,1278.92578125,10.49053192,0.00000000,-1,-1,5); //Faggio
rentcar[15] = AddStaticVehicleEx(462,1317.93640137,1278.68676758,10.49053192,0.00000000,-1,-1,5); //Faggio
rentcar[16] = AddStaticVehicleEx(481,1282.74865723,1290.92309570,10.42908859,272.00000000,-1,-1,5); //BMX
rentcar[17] = AddStaticVehicleEx(481,1282.62097168,1293.31713867,10.42908859,271.99951172,-1,-1,5); //BMX
rentcar[18] = AddStaticVehicleEx(481,1282.70117188,1296.41113281,10.42908859,271.99951172,-1,-1,5); //BMX
rentcar[19] = AddStaticVehicleEx(481,1282.96948242,1299.54357910,10.42908859,271.99951172,-1,-1,5); //BMX
and a code
PHP Code:
public IsARentableCar(carid)
{
for(new i = 0; i < sizeof(rentcar); i++)
{
if(carid == rentcar[i]) return 1;
}
return 0;
}
PHP Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsARentableCar(newcar))
{
if(GetPlayerVehicleSeat(playerid) == 1)
{
if(rentkey[playerid] == 0)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_RED,"You do not have a rent card.Go buy one.");
}
if(rentkey[playerid] == 1)
{
SendClientMessage(playerid,COLOR_RED,"Watch out,When you exit the vehicle you wont be able to ride it again.");
}
}
}
return 1;
}
Now when I get into any vehicle
it doesnt says/does anything.
I can ride the vehicle free.
What can I do about it ?
Thanks alot.