Licenses help -
JoshP - 12.07.2013
Okay so i'm scripting something where you go to the DMV, and you can buy a driving license, a weapon license or a flying license, and also you can do /mylicenses to show which ones you've got.
But when i restart the server /mylicenses reset how do i save?
Re: Licenses help -
JoshP - 12.07.2013
. help
Re: Licenses help -
arjanforgames - 12.07.2013
I guess you have a register system.
pawn Код:
enum pInfo
{
pDrivingL,
pWeaponL,
pFlyingL
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Add those three types, you probably know how to save them? Use 0 if he hasn't got the license and 1 if he has.
If he passes his driving/weapon/flying test just say:
pawn Код:
PlayerInfo[playerid][pDrivingL] = 1;
or
pawn Код:
PlayerInfo[playerid][pWeaponL] = 1;
or
pawn Код:
PlayerInfo[playerid][pFlyingL] = 1;
Then what you can do is:
(This code can be a lot shorter but I just want to show clearly how it's done!)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mylicenses", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][pDrivingL] == 1)
{
SendClientMessage(playerid, -1, "Drivers License: Aquired");
}
else
{
SendClientMessage(playerid, -1, "Drivers License: Not Aquired");
}
if(PlayerInfo[playerid][pWeaponL] == 1)
{
SendClientMessage(playerid, -1, "Weapon License: Aquired");
}
else
{
SendClientMessage(playerid, -1, "Weapon License: Not Aquired");
}
if(PlayerInfo[playerid][pFlyingL] == 1)
{
SendClientMessage(playerid, -1, "Flying License: Aquired");
}
else
{
SendClientMessage(playerid, -1, "Flying License: Not Aquired");
}
return 1;
}
return 0;
}
I have not tried this code but I think it will work.
Re: Licenses help -
Nines - 12.07.2013
hmm check ur pm Josh
Re: Licenses help -
JoshP - 12.07.2013
You both have it wrong, sorry about this, I havn't explained well. I've already got the code made up, here it is. I need to make it so the /mylic thing saves when server restarts, any help?
pawno
Код:
CMD:buydrivinglic(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2046.6372,-1908.0178,13.5469)) return SendClientMessage(playerid,-1,"You must be near the DMV to obtain a driving license.");
if(HasDrivingLic[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You already have a driving license.");
if(HasDrivingLic[playerid] == 0)
(HasDrivingLic[playerid] = 1);
GivePlayerMoney(playerid, -2000);
SendClientMessage(playerid, -1, "You've bought a driving license for $2000, drive safely, otherwise the police department may suspend it from you.");
return 1;
}
CMD:buygunlic(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2046.6372,-1908.0178,13.5469)) return SendClientMessage(playerid,-1,"You must be near the DMV to obtain a gun license.");
if(HasGunLic[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You already have a gun license.");
if(HasGunLic[playerid] == 0)
(HasGunLic[playerid] = 1);
GivePlayerMoney(playerid, -25000);
SendClientMessage(playerid, -1, "You've bought a gun license for $25,000, don't do anything illegal with it or the police department can suspend you.");
return 1;
}
CMD:buyflyinglic(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid, 5.0, 2046.6372,-1908.0178,13.5469)) return SendClientMessage(playerid,-1,"You must be near the DMV to obtain a flying license.");
if(HasFlyingLic[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You already have a pilot license.");
if(HasFlyingLic[playerid] == 0)
(HasFlyingLic[playerid] = 1);
GivePlayerMoney(playerid, -2000);
SendClientMessage(playerid, -1, "You've bought a pilot license for $2000, you are now able to fly with any helicopter/plane.");
return 1;
}
CMD:mylic(playerid, params[])
{
new lic[128], drivinglic[12], gunlic[12],flyinglic[12];
if(HasDrivingLic[playerid] == 0) drivinglic = "Not Passed";
else drivinglic = "Passed";
if(HasGunLic[playerid] == 0) gunlic = "Not Passed";
else gunlic = "Passed";
if(HasFlyingLic[playerid] == 0) flyinglic = "Not Passed";
else flyinglic = "Passed";
format(lic, sizeof(lic), "** Your Licenses - [Driving]: %s || [Gun]: %s || [Flying]: %s", drivinglic,gunlic,flyinglic);
SendClientMessage(playerid, -1, lic);
return 1;
}
Re: Licenses help -
arjanforgames - 12.07.2013
As I said, I guess you have a register system?
Add those lines:
pawn Код:
enum pInfo
{
pDrivingL,
pWeaponL,
pFlyingL
}
new PlayerInfo[MAX_PLAYERS][pInfo];
If he passes his driving/weapon/flying test just say:
PlayerInfo[playerid][pDrivingL] = 1;
PlayerInfo[playerid][pWeaponL] = 1;
PlayerInfo[playerid][pFlyingL] = 1;
Re: Licenses help -
JoshP - 12.07.2013
i use ladminv2, where do i put these codes?
Re: Licenses help -
arjanforgames - 12.07.2013
Look for the enum which stores all variables to be saved.
Re: Licenses help -
JoshP - 12.07.2013
ok i found it in ladmin. but i put my script into another filterscript is that a problem?
here it is
enum PlayerData
{
Registered,
LoggedIn,
Level,
Muted,
Caps,
Jailed,
JailTime,
Frozen,
FreezeTime,
Kills,
Deaths,
hours,
mins,
secs,
TotalTime,
ConnectTime,
MuteWarnings,
Warnings,
Spawned,
TimesSpawned,
God,
GodCar,
DoorsLocked,
SpamCount,
SpamTime,
PingCount,
PingTime,
BotPing,
pPing[PING_MAX_EXCEEDS],
blip,
blipS,
pColour,
pCar,
SpecID,
SpecType,
bool:AllowedIn,
FailLogin,
Re: Licenses help -
JoshP - 12.07.2013
help