Need Code
#1

I made my rent system and everything works fine.
I just have a little problem:
"I rent vehicle than enter and left,and it says that i didn't rented that vehicle".

Here's @ONPLAYERSTATECHANGE:

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
Vozilo GetPlayerVehicleID(playerid);
    {
        if(
newstate == PLAYER_STATE_DRIVER && Vozilo == Rent[0] || Vozilo == Rent[1] || Vozilo == Rent[2] || Vozilo == Rent[3] || Vozilo == Rent[4] || Vozilo == Rent[5] || Vozilo == Rent[6] || Vozilo == Rent[7])
        {
            if(
Rentano[playerid] != 0) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Vozilo je vec iznajmljeno") && RemovePlayerFromVehicle(playerid);
            {
                
ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,""COLOR_ZUTA"Rent Vozila","{FFFFFF} ** "COLOR_SIVA"5 {FFFFFF}minuta\n** "COLOR_SIVA"15 {FFFFFF} minuta\n** "COLOR_SIVA"30 {FFFFFF} minuta","Iznajmi","Izlaz");
                
TogglePlayerControllable(playerid,0);
            }
        }
        return 
1;
    }

You can see "if(Rentano[playerid] != 0)". I am using that to check if that vehicle is rented or not. But i would like to ignore it when is rented ? :=
Reply
#2

becoz you already returned

PHP код:
if(Rentano[playerid] != 0
       { 
            
SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Vozilo je vec iznajmljeno") && RemovePlayerFromVehicle(playerid); 
       }
       else
       { 
            
ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,""COLOR_ZUTA"Rent Vozila","{FFFFFF} ** "COLOR_SIVA"5 {FFFFFF}minuta\n** "COLOR_SIVA"15 {FFFFFF} minuta\n** "COLOR_SIVA"30 {FFFFFF} minuta","Iznajmi","Izlaz"); 
            
TogglePlayerControllable(playerid,0); 
        } 
Reply
#3

Nothing. Again when i leave it,and reenter the vehicle it says "Ovo vozilo je iznajmljeno" or "This vehicle is already rented"
Reply
#4

Any more examples?
Reply
#5

BUMP? Come on guys :/
Reply
#6

Hello!

First you have to write the code in the following way:
PHP код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new 
Vozilo GetPlayerVehicleID(playerid);
    if(
newstate == PLAYER_STATE_DRIVER && Vozilo == Rent[0] || Vozilo == Rent[1] || Vozilo == Rent[2] || Vozilo == Rent[3] || Vozilo == Rent[4] || Vozilo == Rent[5] || Vozilo == Rent[6] || Vozilo == Rent[7])
    {
        if(
Rentano[playerid] != 0)return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Vozilo je vec iznajmljeno"),RemovePlayerFromVehicle(playerid);
        
ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,""COLOR_ZUTA"Rent Vozila","{FFFFFF} ** "COLOR_SIVA"5 {FFFFFF}minuta\n** "COLOR_SIVA"15 {FFFFFF} minuta\n** "COLOR_SIVA"30 {FFFFFF} minuta","Iznajmi","Izlaz");
         
TogglePlayerControllable(playerid,0);
    }
    return 
1;

So, if it doesn't do you should us send the code where you use Rentano[playerid], but where are you set the value?

Mencent
Reply
#7

Code where i set value of Rentano[playerid]:

PHP код:
case DIALOG_RENT:
        {
            if(!
responseSendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Odustali ste od iznajmljivanja vozila") && RemovePlayerFromVehicle(playerid) && TogglePlayerControllable(playerid,1);
            {
                if(
response)
                {
                    switch(
listitem)
                    {
                        case 
0:
                        {
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Iznajmili ste vozilo na"COLOR_SIVA" 2{FFFFFF} minuta");
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Ukoliko odlucite vratit vozilo prije kraja iznajmljivanja "COLOR_SIVA"- "COLOR_NARANCASTA"/unrent");
                            
Rentano[playerid] = 1;
                            
TogglePlayerControllable(playerid,1);
                            
RentTimer SetTimerEx("RentVozila"120000true"i"playerid);
                        }
                        case 
1:
                        {
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Iznajmili ste vozilo na"COLOR_SIVA" 5{FFFFFF} minuta");
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Ukoliko odlucite vratit vozilo prije kraja iznajmljivanja "COLOR_SIVA"- "COLOR_NARANCASTA"/unrent");
                            
Rentano[playerid] = 1;
                            
TogglePlayerControllable(playerid,1);
                            
RentTimer SetTimerEx("RentVozila"300000true"i"playerid);
                        }
                        case 
3:
                        {
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Iznajmili ste vozilo na"COLOR_SIVA" 15{FFFFFF} minuta");
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Ukoliko odlucite vratit vozilo prije kraja iznajmljivanja "COLOR_SIVA"- "COLOR_NARANCASTA"/unrent");
                            
Rentano[playerid] = 1;
                            
TogglePlayerControllable(playerid,1);
                            
RentTimer SetTimerEx("RentVozila"900000true"i"playerid);
                        }
                        case 
4:
                        {
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Iznajmili ste vozilo na"COLOR_SIVA" 30{FFFFFF} minuta");
                            
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Ukoliko odlucite vratit vozilo prije kraja iznajmljivanja "COLOR_SIVA"- "COLOR_NARANCASTA"/unrent");
                            
Rentano[playerid] = 1;
                            
TogglePlayerControllable(playerid,1);
                            
RentTimer SetTimerEx("RentVozila"1800000true"i"playerid);
                        }
                    }
                }
            }
            return 
1;
        } 
Than function where I end that array:

Command - Unrent:

PHP код:
CMD:unrent(playerid,params[])
{
    new 
Vozilo GetPlayerVehicleID(playerid);
    if(
Rentano[playerid] != 1) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste iznajmili vozilo");
    {
        if(
Vozilo == Rent[0] || Vozilo == Rent[1] || Vozilo == Rent[2] || Vozilo == Rent[3] || Vozilo == Rent[4] || Vozilo == Rent[5] || Vozilo == Rent[6] || Vozilo == Rent[7]) RemovePlayerFromVehicle(playerid) && SetVehicleToRespawn(Vozilo);
        
Rentano[playerid] = 0;
        
KillTimer(RentTimer);
        
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Prestali ste iznajmljivati vozilo");
    }
    return 
1;

And OnPlayerDisconnect:

PHP код:
    //Rent Vozila array//
    
{
        
Rentano[playerid] = 0;
        
KillTimer(RentTimer);
    }
    return 
1
Reply
#8

You aren't setting anything to tell you which vehicle they have rented. You're just saying they've rented something, which could be any of the rentable vehicles (there's more wrong than that but I want to start in small steps).
Reply
#9

I wouldn't ask this question that i made a value which set somebodey rent?
Reply
#10

Listen,you are checking if player is renting a car,if he is renting any car it shows him that this car is rented,you should change your OnPlayerStateChange code,add these
pawn Код:
new PlayerRentedVehicleID[MAx_PLAYERS];
and under the code that lets the player rent the car,add:
pawn Код:
PlayerRentedVehicleID[playerid] = GetPlayerVehicleID(playerid);
and when he unrents:
pawn Код:
PlayerRentedVehicleID[playerid] = 0;
and to detect if player is renting the car he entered use:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new Vozilo = GetPlayerVehicleID(playerid);
    {
        if(newstate == PLAYER_STATE_DRIVER && Vozilo == Rent[0] || Vozilo == Rent[1] || Vozilo == Rent[2] || Vozilo == Rent[3] || Vozilo == Rent[4] || Vozilo == Rent[5] || Vozilo == Rent[6] || Vozilo == Rent[7])
        {
            if(Rentano[playerid] == 0 && PlayerRentedVehicleID[playerid] == 0)
            {
                ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,""COLOR_ZUTA"Rent Vozila","{FFFFFF} ** "COLOR_SIVA"5 {FFFFFF}minuta\n** "COLOR_SIVA"15 {FFFFFF} minuta\n** "COLOR_SIVA"30 {FFFFFF} minuta","Iznajmi","Izlaz");
                TogglePlayerControllable(playerid,0);
            }
            else if(Rentano[playerid] == 1 && PlayerRentedVehicleID[playerid] != Vozilo)
            {
                RemovePlayerFromVehicle(playerid); //he has rented a car but this is not his rented car
            }
            else
            {
                SendClientMessage(playerid, -1, "This is your rented car"); //he entered his rented vehicle
            }  
        }
        return 1;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)