Rent system - States
#1

Hello.

Problem with rent system in the state.

- There is no errors,but when I enter "rentable" vehicle nothing doesn't show. + I know that is problem something with onplayerstatechange but I don't know how to fix.

- Codes:

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
newcar GetPlayerVehicleID(playerid);
    if(
newstate == 1)
    {
        if(
RentVozila(newcar))
        {
            if(
Rentano[playerid] != newcar)
            {
                
ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,"Iznamjite vozilo","[1] Rent Vrijeme - N/A (500$)","Odaberi","Izlaz");
                
TogglePlayerControllable(playerid,0);
            }
        }
    }
    return 
1;

Unrent command:

PHP код:
CMD:unrentaj(playerid,params[])
{
       new 
idcar GetPlayerVehicleID(playerid);
       if(
Rentano[playerid] != 299)
       {
        if(
idcar == Rentano[playerid])
        {
               
TogglePlayerControllable(playerid1);
        }
        
SetVehicleToRespawn(Rentano[playerid]);
          
Rentano[playerid] = 299;
          
SendClientMessage(playerid,-1,"{00C0FF}WG:{FFFFFF} Uspjesno ste unrentali vozilo");
    }
    return 
1;

Rent dialog:

PHP код:
        case DIALOG_RENT:
        {
            new 
poruka[128];
            if(!
responseSendClientMessage(playerid,-1,"{00C0FF}WG:{FFFFFF} Izasli ste iz iznajmljivanja vozila") && RemovePlayerFromVehicle(playerid);
            {
                if(
response)
                {
                    if(
GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,-1,"{F81414}Greska:{FFFFFF} Nemate dovoljno novca na racunu");
                    if(
Rentano[playerid] != 299) return SendClientMessage(playerid,-1,"{F81414}Greska:{FFFFFF} Vec imate iznajmljeno vozilo");
                    {
                        for(new 
i=0i<MAX_PLAYERSi++)
                        if(
Rentano[i] == GetPlayerVehicleID(playerid)) return SendClientMessage(playerid,-1,"{F81414}Greska:{FFFFFF} Netko je vec rentovo ovo vozilo");
                        {
                            
GivePlayerMoney(playerid,-500);
                            
Rentano[playerid] = GetPlayerVehicleID(playerid);
                            
format(poruka,sizeof(poruka),"~g~ Uspjesno ste rentali vozilo!\nAko ne koristite ~y~/unrent");
                            
GameTextForPlayer(playerid,poruka,5000,1);
                        }
                    }
                }
            }
            return 
1;
        } 
Thank you very much!
Reply
#2

maybe use it on OnPlayerEnterVehicle..

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
   if(RentVozila(vehicleid))
   {
      if(Rentano[playerid] != vehicleid)
      {
         ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_LIST,"Iznamjite vozilo","[1] Rent Vrijeme - N/A (500$)","Odaberi","Izlaz");
         TogglePlayerControllable(playerid,0);
      }
   }
   return 1;
}
Reply
#3

No. I want to use onplayerstatechange because if I use onplayerentervehicle,when player enter vehicles with range of 5 m he gets a dialog -_-. I want player to sit in vehicle and then get
Reply
#4

BUMP!
Reply
#5

Show your RentVozila function.
Reply
#6

PHP код:
public RentVozila(carid)
{
   for(new 
0sizeof(Rent); i++)
   {
      if(
carid == Rent[i])   return 1;
   }
   return 
0;

Reply
#7

And...?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)