Rent system - States - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rent system - States (
/showthread.php?tid=567894)
Rent system - States -
NoDi522 - 17.03.2015
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(playerid, newstate, oldstate)
{
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(playerid, 1);
}
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(!response) SendClientMessage(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=0; i<MAX_PLAYERS; i++)
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!
Re: Rent system - States -
ReD_HunTeR - 17.03.2015
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;
}
Re: Rent system - States -
NoDi522 - 17.03.2015
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
Re: Rent system - States -
NoDi522 - 18.03.2015
BUMP!
Re: Rent system - States -
CalvinC - 18.03.2015
Show your RentVozila function.
Re: Rent system - States -
NoDi522 - 18.03.2015
PHP код:
public RentVozila(carid)
{
for(new i = 0; i < sizeof(Rent); i++)
{
if(carid == Rent[i]) return 1;
}
return 0;
}
Re: Rent system - States -
NoDi522 - 18.03.2015
And...?