[HELP P!x3L] Rent bikes
#1

I have annother problem today :P but now is for rent bikes :S

pawn Код:
new rentbic;

public OnGameModeInit()
{
    rentbic = AddStaticVehicle(510,1625.92614746,-1896.12182617,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1623.30200195,-1895.91040039,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1620.91601562,-1895.90014648,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1618.71215820,-1895.67626953,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1616.32617188,-1895.66577148,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1614.12231445,-1895.44189453,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1611.93383789,-1895.41577148,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1626.01855469,-1892.11779785,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1623.43530273,-1892.12280273,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1621.04956055,-1892.11279297,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1618.86059570,-1892.08666992,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1616.47460938,-1892.07592773,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1614.28637695,-1892.04956055,13.24651337,0.00000000,-1,-1); //Mountain Bike
    rentbic = AddStaticVehicle(510,1612.09790039,-1892.02319336,13.24651337,0.00000000,-1,-1); //Mountain Bike
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        for(new i;i<MAX_VEHICLES;i++)
        {
            if(i == rentbic)
            {
                if(GetPVarInt(rentbic, "BicRentan") == 0)
                {
                    TogglePlayerControllable(playerid, 0);
                    GameTextForPlayer(playerid, "Upisite '/iznajmi 3' ~n~kako biste iznajmili ~n~ovaj bicikl za 10$!", 5000, 4);
                }
            }
        }
    }
    return 1;
}
OK now, that's all work, but, when i get on bike, it write "Upisite '/iznajmi 3' ~n~kako biste iznajmili ~n~ovaj bicikl za 10$!" but its removing me from bike :SSS why i aint type RemovePlayerFromVehicle(playerid); so why is removing me from vehicle?
Reply
#2

I don't particularly understand the logic in use here. What are you trying to achieve? If you want to check if the vehicle ID of the player matches the vehicle ID stored in "rentbic" then there's no need for a loop, just:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) == rentbic)
        {
            if(GetPVarInt(rentbic, "BicRentan") == 0)
            {
                TogglePlayerControllable(playerid, 0);
                GameTextForPlayer(playerid, "Upisite '/iznajmi 3' ~n~kako biste iznajmili ~n~ovaj bicikl za 10$!", 5000, 4);
            }
        }
    }
    return 1;
}
You may also want to know that the variable is only going to be storing the vehicle ID of the last vehicle, so only the last moutain bike will match in the if statement. I suggest either having an array or simply checking the model of the vehicle if you want it to do this for all mountain bikes!
Reply
#3

I want that: when i go to bike that you i am not controllable, and that i can type "/iznajmi" (/rent on english) to rent bike only that, but i am removing from bike when i go to the bike, and i dont know how to make that i DONT remove from vehicle and i dont know WHY i am removing from vehicle...
Reply
#4

Well you must have RemovePlayerFromVehicle somewhere in your code that is causing this, however I don't see it in the snippet that you posted
Reply
#5

yea, that is problem, i dont have RemovePlayerFromVehicle, but server removing me from vehicle, i cant move, and its write that for rent bike :S but why i am removing from vehicle? I put CMD for /rent but if i aint in bike, i cant rent it, so i want to solve that :S
Reply
#6

Ok now i figured out what is it but i dont know how to solve problem :P i put for 2 models of vehicles (mountain bike and bus) for bus i am put RemovePlayerFromVehicle, but, when i go to renbic, server do all of that what i write for bus and for bikes, so i am write for bus that if you are not bus driver you are removed from bus, and i am write for bikes that if is rent that you can rent it. But now if i go into the bus i will recive message for bikes (that i can rent it) and i will be removed, and i will be controllable 0, here is code for all of that:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        for(new i;i<MAX_VEHICLES;i++)
        {
            if(i == bus)
            {
                if(GetPVarInt(playerid, "VozacAutobusa") == 0)
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid, -1, ""#ZELENA"SONY RP:"#PLAVA"Niste vozac autobusa pa nemozete voziti autobus!");
                }
            }
            else if(i == rentbic)
            {
                if(GetPVarInt(rentbic, "BicRentan") == 0)
                {
                    TogglePlayerControllable(playerid, 0);
                    GameTextForPlayer(playerid, "Upisite '/iznajmi 3' ~n~kako biste iznajmili ~n~ovaj bicikl za 10$!", 5000, 4);
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)