Problem with rent cars.
#1

So I tried to make rent cars for my server
I created 3 variables(sorry for my bad einglish)
PHP Code:
new rentcar[20];
new 
newcar;
new 
rentkey[MAX_PLAYERS]; 
Now
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 
Added a public
and a code
PHP Code:
public IsARentableCar(carid)
{
    for(new 
0sizeof(rentcar); i++)
    {
        if(
carid == rentcar[i]) return 1;
    }
    return 
0;

And onPlayerEnterVehicle
PHP Code:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    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
Reply
#2

pawn Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        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;
}
Reply
#3

Thanks alot ! No need to explain I got it .
Reply
#4

[ pawn ] brackets work great instead of php
Reply
#5

Okey thank you will use it next time.
Reply
#6

Quote:
Originally Posted by Mean
View Post
pawn Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        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;
}
Oh ... It doesnt work ... doesnt give errors but doesnt work .
Reply
#7

UPPP
Some one please ?
Reply
#8

Quote:
Originally Posted by bijoyekuza
View Post
UPPP
Some one please ?
because of

pawn Code:
if( newstate == PLAYER_STATE_DRIVER )
and

pawn Code:
GetPlayerVehicleSeat(playerid) == 1)
He should be driver and on a passenger seat => Cant work

So, I rly hate it if guys use array for something like that
pawn Code:
new
    rentcar_Last,
    rentcar_First,
    bool: rentkey[MAX_PLAYERS];
pawn Code:
//OnGameModeInit
rentcar_First = AddStaticVehicleEx(510,1560.93286133,-2309.08129883,13.24319458,91.99993896,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1560.88171387,-2311.87597656,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.00732422,-2315.56152344,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.11535645,-2318.67944336,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.23120117,-2321.97534180,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.34765625,-2325.31958008,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.46789551,-2328.74047852,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.57324219,-2331.73730469,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.69628906,-2335.23388672,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(468,-1330.38940430,-284.64837646,13.90843773,0.00000000,-1,-1,15); //Sanchez
AddStaticVehicleEx(468,-1331.91455078,-285.06213379,13.90843773,0.00000000,-1,-1,5); //Sanchez
AddStaticVehicleEx(462,1305.86437988,1278.80163574,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1308.87707520,1278.86083984,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1311.88745117,1278.89587402,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1314.59558105,1278.92578125,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1317.93640137,1278.68676758,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(481,1282.74865723,1290.92309570,10.42908859,272.00000000,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.62097168,1293.31713867,10.42908859,271.99951172,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.70117188,1296.41113281,10.42908859,271.99951172,-1,-1,5); //BMX
rentcar_Last = AddStaticVehicleEx(481,1282.96948242,1299.54357910,10.42908859,271.99951172,-1,-1,5); //BMX
pawn Code:
//IsARentableCar(vehicleid) - Should be somewhere above
#define IsARentableCar(%0) (rentcar_First <= (%0) <= rentcar_Last)
pawn Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        newstate = GetPlayerVehicleID(playerid);
        if(IsARentableCar(newstate))
        {
            if(rentkey[playerid] == false)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid,COLOR_RED,"You do not have a rent card.Go buy one.");
            } else {
                SendClientMessage(playerid,COLOR_RED,"Watch out,When you exit the vehicle you wont be able to ride it again.");
            }
        }  
    }
    return true;
}
Reply
#9

Quote:
Originally Posted by Nero_3D
View Post
because of

pawn Code:
if( newstate == PLAYER_STATE_DRIVER )
and

pawn Code:
GetPlayerVehicleSeat(playerid) == 1)
He should be driver and on a passenger seat => Cant work

So, I rly hate it if guys use array for something like that
pawn Code:
new
    rentcar_Last,
    rentcar_First,
    bool: rentkey[MAX_PLAYERS];
pawn Code:
//OnGameModeInit
rentcar_First = AddStaticVehicleEx(510,1560.93286133,-2309.08129883,13.24319458,91.99993896,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1560.88171387,-2311.87597656,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.00732422,-2315.56152344,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.11535645,-2318.67944336,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.23120117,-2321.97534180,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.34765625,-2325.31958008,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.46789551,-2328.74047852,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.57324219,-2331.73730469,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.69628906,-2335.23388672,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(468,-1330.38940430,-284.64837646,13.90843773,0.00000000,-1,-1,15); //Sanchez
AddStaticVehicleEx(468,-1331.91455078,-285.06213379,13.90843773,0.00000000,-1,-1,5); //Sanchez
AddStaticVehicleEx(462,1305.86437988,1278.80163574,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1308.87707520,1278.86083984,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1311.88745117,1278.89587402,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1314.59558105,1278.92578125,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1317.93640137,1278.68676758,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(481,1282.74865723,1290.92309570,10.42908859,272.00000000,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.62097168,1293.31713867,10.42908859,271.99951172,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.70117188,1296.41113281,10.42908859,271.99951172,-1,-1,5); //BMX
rentcar_Last = AddStaticVehicleEx(481,1282.96948242,1299.54357910,10.42908859,271.99951172,-1,-1,5); //BMX
pawn Code:
//IsARentableCar(vehicleid) - Should be somewhere above
#define IsARentableCar(%0) (rentcar_Last <= (%0) <= rentcar_First)
pawn Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        newstate = GetPlayerVehicleID(playerid);
        if(IsARentableCar(newstate))
        {
            if(rentkey[playerid] == false)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid,COLOR_RED,"You do not have a rent card.Go buy one.");
            } else {
                SendClientMessage(playerid,COLOR_RED,"Watch out,When you exit the vehicle you wont be able to ride it again.");
            }
        }  
    }
    return true;
}

HUH ?
so
on top I got :
Code:
new rentcar_Last,rentcar_First,bool: rentkey[MAX_PLAYERS];
Code:
#define IsARentableCar(%0) (rentcar_Last <= (%0) <= rentcar_First)
Then ongamemodeinit
I got
Code:
rentcar_First = AddStaticVehicleEx(510,1560.93286133,-2309.08129883,13.24319458,91.99993896,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1560.88171387,-2311.87597656,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.00732422,-2315.56152344,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.11535645,-2318.67944336,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.23120117,-2321.97534180,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.34765625,-2325.31958008,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.46789551,-2328.74047852,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.57324219,-2331.73730469,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(510,1561.69628906,-2335.23388672,13.24319458,91.99951172,-1,-1,5); //Mountain Bike
AddStaticVehicleEx(468,-1330.38940430,-284.64837646,13.90843773,0.00000000,-1,-1,15); //Sanchez
AddStaticVehicleEx(468,-1331.91455078,-285.06213379,13.90843773,0.00000000,-1,-1,5); //Sanchez
AddStaticVehicleEx(462,1305.86437988,1278.80163574,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1308.87707520,1278.86083984,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1311.88745117,1278.89587402,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1314.59558105,1278.92578125,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(462,1317.93640137,1278.68676758,10.49053192,0.00000000,-1,-1,5); //Faggio
AddStaticVehicleEx(481,1282.74865723,1290.92309570,10.42908859,272.00000000,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.62097168,1293.31713867,10.42908859,271.99951172,-1,-1,5); //BMX
AddStaticVehicleEx(481,1282.70117188,1296.41113281,10.42908859,271.99951172,-1,-1,5); //BMX
rentcar_Last = AddStaticVehicleEx(481,1282.96948242,1299.54357910,10.42908859,271.99951172,-1,-1,5); //BMX
Then I got
Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        newstate = GetPlayerVehicleID(playerid);
        if(IsARentableCar(newstate))
        {
            if(rentkey[playerid] == false)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid,COLOR_RED,"You do not have a rent card.Go buy one.");
            } else {
                SendClientMessage(playerid,COLOR_RED,"Watch out,When you exit the vehicle you wont be able to ride it again.");
            }
        }
    }
    return true;
}
And lets say That I have rentkey[playerid] = false; at onplayerconnect


Doesnt give any errors but it doesnt work ... I can still ride the bikes for free.
Reply
#10

uppp
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)