How to make, that only players with License can rent a car!? -
Sensitive - 23.09.2011
pawn Код:
if(strcmp(cmd, "/rentcar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154)
{
new hirefee = HireCost(GetPlayerVehicleID(playerid));
if(SBizzInfo[0][sbProducts] == 0)
{
GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
return 1;
}
if (GetPlayerMoney(playerid) < 500)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have that much cash !");
return 1;
}
if(HireCar[playerid] != 299)
{
gCarLock[HireCar[playerid]] = 0;
UnLockCar(HireCar[playerid]);
SendClientMessage(playerid, COLOR_GREY, "You need unrent your current car/bike/boat first !");
return 1;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(HireCar[i] == GetPlayerVehicleID(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Someone already rents this car !");
return 1;
}
}
Where do i add
pawn Код:
PlayerInfo[playerid][pCarLic] = 0;
And a text, like if the player doesent have the license he would get this message: Sorry, we canno't rent you a car becouse you don't have a valid drivers license.
Please help.. I cant figure this out myself
.
Re: How to make, that only players with License can rent a car!? -
Sensitive - 23.09.2011
Any help?
Re: How to make, that only players with License can rent a car!? -
Sensitive - 23.09.2011
Help?
Re: How to make, that only players with License can rent a car!? -
GrimR - 23.09.2011
Ok straight up,
Every player needs a variable to store whether they have a license or not, it can be 0/1 or true/false that is up to you, which could go into as a new value with the players information enumeration.
At some point you need to give/take away the license, which is as simple as changing that value.
For renting a car, you obviously need to check the player enum[playerid][hasLicense] == 1 (they have a license), here is a mock example:
if (enum[playerid][hasLicense] == 1) { // You have a license. Give rental vehicle. }
else { // You do not have license, so no vehicle. }
enum/array or w/e being the name of what holds all the different properties for the player, [playerid] gives you a return number to access that array (so player[40][hasLicense] for example) and [hasLicense] is your newly add variable for storing and tracking if each user has a license or not.
Re: How to make, that only players with License can rent a car!? -
MP2 - 23.09.2011
if(!PlayerInfo[playerid][pCarLic]) return SendClientMessge(playerid, color, "You must have a valid license to rent a vehicle.");
Re: How to make, that only players with License can rent a car!? -
Sensitive - 23.09.2011
Umm lol?
I already have the variable
pawn Код:
PlayerInfo[playerid][pCarLic] = 0;
I need the hwole code like
pawn Код:
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154)
{
new hirefee = HireCost(GetPlayerVehicleID(playerid));
if(SBizzInfo[0][sbProducts] == 0)
{
GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
return 1;
}
if (GetPlayerMoney(playerid) < 500)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have that much cash !");
return 1;
}
if(HireCar[playerid] != 299)
{
gCarLock[HireCar[playerid]] = 0;
UnLockCar(HireCar[playerid]);
SendClientMessage(playerid, COLOR_GREY, "You need unrent your current car/bike/boat first !");
return 1;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(HireCar[i] == GetPlayerVehicleID(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Someone already rents this car !");
return 1;
}
}
Now where do i put the
pawn Код:
if(!PlayerInfo[playerid][pCarLic]) return SendClientMessge(playerid, color, "You must have a valid license to rent a vehicle.");
Re: How to make, that only players with License can rent a car!? -
MP2 - 23.09.2011
Firstly, show the entire command.
Secondly, why do you have IsPlayerConnected in a command..? Players that aren't on the server can't exactly type commands can they.
Re: How to make, that only players with License can rent a car!? -
Sensitive - 23.09.2011
Dude, that is the entire command.
And i dont know why there is IsPlayerConnected
My friend wants me to translate the GM, and add some things.
Re: How to make, that only players with License can rent a car!? -
Basicz - 23.09.2011
pawn Код:
if(strcmp(cmd, "/rentcar", true) == 0)
{
if(!PlayerInfo[playerid][pCarLic]) return SendClientMessage(playerid, color, "You must have a valid license to rent a vehicle.");
if(IsPlayerConnected(playerid))
{
if(GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154)
{
new hirefee = HireCost(GetPlayerVehicleID(playerid));
if(SBizzInfo[0][sbProducts] == 0)
{
GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
return 1;
}
if (GetPlayerMoney(playerid) < 500)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have that much cash !");
return 1;
}
if(HireCar[playerid] != 299)
{
gCarLock[HireCar[playerid]] = 0;
UnLockCar(HireCar[playerid]);
SendClientMessage(playerid, COLOR_GREY, "You need unrent your current car/bike/boat first !");
return 1;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(HireCar[i] == GetPlayerVehicleID(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Someone already rents this car !");
return 1;
}
}
// err? your command is not full :D