Hey Friends I Am Having Problem With PPC_Business And JLAdmin…..
And The Problem Is That After Typing /createbusiness When I Click On Any Business Type Like Bar, Disco, etc….
“Please enter a another nick….Unacceptable NickName. Please only use (0-9, a-z, [], (), $, @, ., _ and=”
Then PPC_Business Dialogs Are Not Working I Mean Then When I select A Business Type Then Nothing Appears Nor Even Business Get Created…
Code:
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
new Jfile[100],pIP[16],string[40],str[60],buf[145],year,month,day,hour,mins,sec;
new seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs];
if(strlen(inputtext) < 3 || strlen(inputtext) > 20)
{
if(MustRegister == 1) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registration Error", "Enter the password:\n{FF0000}*Password length must be between 3 - 20 characters", "Register", "Kick");
else return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registration Error", "Enter the password:\n{FF0000}*Password length must be between 3 - 20 characters", "Register", "No Thanks");
}
getdate(year, month, day);
gettime(hour,mins,sec);
GetPlayerIp(playerid,pIP,16);
format(string, 40,"%d/%d/%d at %d:%d:%d", day,month,year,hour,mins,sec);
format(str, 60,"%d/%d/%d at %d:%d:%d", day,month,year,hour,mins,sec);
format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));
WP_Hash(buf, sizeof(buf),inputtext);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteString(ACCOUNT, "RegisteredOn", string);
INI_WriteString(ACCOUNT, "RegisteredIP", pIP);
INI_WriteString(ACCOUNT, "LastLoggedIP", pIP);
INI_WriteString(ACCOUNT, "Password",buf);
INI_WriteInt(ACCOUNT, "Level", 0);
INI_WriteInt(ACCOUNT, "Banned", 0);
INI_WriteInt(ACCOUNT, "Donator", 0);
INI_WriteInt(ACCOUNT, "Score", START_SCORE);
INI_WriteInt(ACCOUNT, "Cash", START_CASH);
INI_WriteInt(ACCOUNT, "Kills", 0);
INI_WriteInt(ACCOUNT, "Deaths", 0);
INI_WriteInt(ACCOUNT, "Skin", 0);
INI_WriteInt(ACCOUNT, "Muted", 0);
INI_WriteInt(ACCOUNT, "Autologin", 1);
INI_WriteInt(ACCOUNT, "TotalSeconds", seconds);
INI_WriteString(ACCOUNT, "TotalSpentTime", ConvertTime(seconds,mins,hour,day));
INI_WriteString(ACCOUNT, "LastSeen", str);
INI_Close(ACCOUNT);
pInfo[playerid][Registered] = 1;
pInfo[playerid][Logged] = 1;
#if LoginTextDraw == true
TextDrawHideForPlayer(playerid, TEXT_PASSWORD);
TextDrawHideForPlayer(playerid, TEXT_REGISTER);
TextDrawHideForPlayer(playerid, TEXT_REGISTERED);
CancelSelectTextDraw(playerid);
#endif
format(Jstring, 125, "Your nickname has been successfully registered! | Account: \"%s\" | Password: %s", GetName(playerid), inputtext);
return SendClientMessage(playerid,0x008000C8,Jstring);
}
else if(MustRegister == 1)
{
ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX," {FB0404}You must register an account", "You must register an account if you wish to play on this server!", "Ok", "");
SetTimerEx("KickPlayer",200,false,"d", playerid);
}
}
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
new Jfile[100],pIP[16],buf[145];
format(Jfile, 60, ACCOUNTS_PATH, GetName(playerid));
INI_ParseFile(Jfile, "GetPassword", .bExtra = true, .extra = playerid);
WP_Hash(buf, sizeof(buf),inputtext);
if(strcmp(pInfo[playerid][Password], buf, false) == 0)
{
format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));
INI_ParseFile(Jfile, "LoginPlayer", .bExtra = true, .extra = playerid);
SendClientMessage(playerid,green,"You have been succesfully logged In!");
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Cash]);
pInfo[playerid][Logged] = 1;
GetPlayerIp(playerid,pIP,16);
format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteString(ACCOUNT, "LastLoggedIP", pIP);
INI_Close(ACCOUNT);
#if LoginTextDraw == true
TextDrawHideForPlayer(playerid, TEXT_PASSWORD);
TextDrawHideForPlayer(playerid, TEXT_REGISTER);
TextDrawHideForPlayer(playerid, TEXT_REGISTERED);
CancelSelectTextDraw(playerid);
#endif
}
else
{
pInfo[playerid][LoginAttempts]++;
if(pInfo[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS)
{
format(Jstring, sizeof(Jstring),"%s has been automatically kicked | Reason: 'Incorrect password'", GetName(playerid));
SendToAdmins(orange,Jstring);
ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX, "WARRING","You have been automatically kicked | Reason: 'Incorrect password'", "Ok", "");
SetTimerEx("KickPlayer",100,false,"d",playerid);
return 1;
}
format(Jstring, sizeof(Jstring),"Account \"%s\"\nEnter your password to login\n{FF0000}*Incorrect password", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login error",Jstring, "Login", "Quit");
}
}
#if LoginTextDraw == false
else SetTimerEx("KickPlayer",100,false,"d",playerid);
#endif
}
if (dialogid == DIALOG_PRIVATE_MESSAGE)
{
if(response)
{
new id;
id = pInfo[playerid][Clicked];
if (strlen(inputtext) < 1) return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message","Type your message:\n{FF0000}*Message can NOT be empty","Send","Cancel");
return OnPrivateMessage(playerid, id, inputtext);
}
return 1;
}
if(dialogid == JDIALOGS+201)
{
if(response)
{
new string[128];
GetPVarString(playerid, "SpamMsg", string, 128);
CommandToAdmins(playerid,"Spam");
switch(listitem)
{
case 0: for(new msg; msg < 50; msg++) SendClientMessageToAll(yellow,string);
case 1: for(new msg; msg < 50; msg++) SendClientMessageToAll(white,string);
case 2: for(new msg; msg < 50; msg++) SendClientMessageToAll(blue,string);
case 3: for(new msg; msg < 50; msg++) SendClientMessageToAll(red,string);
case 4: for(new msg; msg < 50; msg++) SendClientMessageToAll(green,string);
case 5: for(new msg; msg < 50; msg++) SendClientMessageToAll(orange,string);
case 6: for(new msg; msg < 50; msg++) SendClientMessageToAll(purple,string);
case 7: for(new msg; msg < 50; msg++) SendClientMessageToAll(pink,string);
case 8: for(new msg; msg < 50; msg++) SendClientMessageToAll(brown,string);
case 9: for(new msg; msg < 50; msg++) SendClientMessageToAll(black,string);
}
}
}
if(dialogid == JDIALOGS+202)
{
if(response)
{
new string[128];
GetPVarString(playerid, "SpamMsg", string, 128);
CommandToAdmins(playerid,"Write");
switch(listitem)
{
case 0: SendClientMessageToAll(yellow,string);
case 1: SendClientMessageToAll(white,string);
case 2: SendClientMessageToAll(blue,string);
case 3: SendClientMessageToAll(red,string);
case 4: SendClientMessageToAll(green,string);
case 5: SendClientMessageToAll(orange,string);
case 6: SendClientMessageToAll(purple,string);
case 7: SendClientMessageToAll(pink,string);
case 8: SendClientMessageToAll(brown,string);
case 9:SendClientMessageToAll(black,string);
}
}
}
if(dialogid == JDIALOGS+203)
{
if(response)
{
switch(listitem)
{
case 0:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_NORMAL);
format(Jstring,sizeof(Jstring),"You have set %s's fighting style to Nomal fighting style",GetName(GetPVarInt(playerid,"player")));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your fighting style to Nomal fighting style",GetName(playerid));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
case 1:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_BOXING);
format(Jstring,sizeof(Jstring),"You have set %s's fighting style to Boxing fighting style",GetName(GetPVarInt(playerid,"player")));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your fighting style to Boxing fighting style",GetName(playerid));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
case 2:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_KUNGFU);
format(Jstring,sizeof(Jstring),"You have set %s's fighting style to KungFu fighting style",GetName(GetPVarInt(playerid,"player")));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your fighting style to KungFu fighting style",GetName(playerid));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
case 3:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_KNEEHEAD);
format(Jstring,sizeof(Jstring),"You have set %s's fighting style to Kneehead fighting style",GetName(GetPVarInt(playerid,"player")));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your fighting style to Kneehead fighting style",GetName(GetPVarInt(playerid,"player")));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
case 4:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_GRABKICK);
format(Jstring,sizeof(Jstring),"You have set '%s' fighting style to Grabkick fighting style",GetName(playerid));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your fighting style to Grabkick fighting style",GetName(GetPVarInt(playerid,"player")));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
case 5:
{
SetPlayerFightingStyle (GetPVarInt(playerid,"player"), FIGHT_STYLE_ELBOW);
format(Jstring,sizeof(Jstring),"You have set %s's fighting style to Elbow fighting style",GetName(GetPVarInt(playerid,"player")));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin %s's has set your fighting style to Elbow fighting style",GetName(playerid));
if(playerid != GetPVarInt(playerid,"player"))SendClientMessage(GetPVarInt(playerid,"player"),orange,Jstring);
}
}
}
}
if(dialogid == JDIALOGS+205)
{
if(response)
{
new id = GetPVarInt(playerid, "TargetID");
switch(listitem)
{
case 0:
{
SetPlayerColor(id,yellow);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'YELLOW'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'YELLOW'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 1:
{
SetPlayerColor(id,white);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'WHITE'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'WHITE'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 2:
{
SetPlayerColor(id,blue);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'BLUE'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'BLUE'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 3:
{
SetPlayerColor(id,red);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'RED'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'RED'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 4:
{
SetPlayerColor(id,green);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'GREEN'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'GREEN'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 5:
{
SetPlayerColor(id,orange);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'ORANGE'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'ORANGE'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 6:
{
SetPlayerColor(id,purple);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'PURPLE'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'PURPLE'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 7:
{
SetPlayerColor(id,pink);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'PINK'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'PINK'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 8:
{
SetPlayerColor(id,brown);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'BROWN'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'BROWN'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
case 9:
{
SetPlayerColor(id,black);
format(Jstring,sizeof(Jstring),"You have set %s' colour to 'BLACK'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Admin '%s' has set your colour to 'BLACK'",GetName(playerid));
if(playerid != id)SendClientMessage(id,orange,Jstring);
}
}
}
}
if(dialogid == JDIALOGS+1)
{
if(response)
{
new file[256],pIP[16];
if(InvalidNick(inputtext)) return ShowPlayerDialog(playerid, JDIALOGS+1, DIALOG_STYLE_INPUT,"Registration error", "Please enter a another nick\n{FF0000}*Unacceptable NickName. Please only use (0-9, a-z, [], (), $, @, ., _ and =)", "Next", "No Thanks");
format(file, 128, ACCOUNTS_PATH, inputtext);
if(!fexist(file))
{
SetPlayerName(playerid,inputtext);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register an account!", "Enter password:", "Register", "No Thanks");
GetPlayerIp(playerid,pIP,16);
format(file,sizeof(file),"JLadmin/Logs/aka.ini");
INI_ParseFile(file,"GetAkaLog");
if(strfind(aka, GetName(playerid), true) == -1)
{
format(file,sizeof(file),"JLadmin/Logs/aka.ini");
format(Jstring,sizeof(Jstring),"%s,%s", aka, GetName(playerid));
new INI:AKA = INI_Open(file);
INI_WriteString(AKA, pIP, Jstring);
INI_Close(AKA);
}
}
else return ShowPlayerDialog(playerid, JDIALOGS+1, DIALOG_STYLE_INPUT,"Registration error", "Please enter a another nick\n{FF0000}*You entered nick name is already using someone else", "Next", "No Thanks");
}
}
if(dialogid == JDIALOGS+4)
{
if(response)
{
new file[128];
format(file, 128, ACCOUNTS_PATH, GetName(playerid));
if(fexist(file))
{
switch(listitem)
{
case 0:
{
new INI:ACCOUNT = INI_Open(file);
INI_WriteInt(ACCOUNT, "Autologin", 1);
INI_Close(ACCOUNT);
return ShowPlayerDialog(playerid, JDIALOGS+204, DIALOG_STYLE_MSGBOX,"Auto login enabled!", "{00FFFF}You have successfully enabled your account auto login system by IP!", "Ok", "");
}
case 1:
{
new INI:ACCOUNT = INI_Open(file);
INI_WriteInt(ACCOUNT, "Autologin", 0);
INI_Close(ACCOUNT);
return ShowPlayerDialog(playerid, JDIALOGS+204, DIALOG_STYLE_MSGBOX,"Auto login disabled!", "{00FFFF}You have disabled your account auto login system!", "Ok", "");
}
}
}
else return ShowPlayerDialog(playerid, JDIALOGS+204, DIALOG_STYLE_MSGBOX,"Error", "{FF0000}You are not registered", "Ok", "");
}
}
if(dialogid == JDIALOGS+5)
{
if(response)
{
switch(listitem)
{
case 0:
{
new id;
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type your message:", GetName(id), id);
return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
}
else return ShowMessage(playerid, red, 2);
}
case 1:
{
new id, h, m, d;
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
new seconds = gettime() - pInfo[id][ConnectedTime] + pInfo[id][TotalSecs];
format(Jstring, sizeof(Jstring), "_Statistics for '%s'_",GetName(id));
SendClientMessage(playerid, green, Jstring);
format(Jstring, sizeof(Jstring), "Score: %d | Money: $%d | Kills: %d | Deaths: %d | Ratio: %0.2f | Total spent Time: %s", GetPlayerScore(id), GetPlayerMoney(id), pInfo[id][Kills], pInfo[id][Deaths], Float:pInfo[id][Kills]/Float:pInfo[id][Deaths], ConvertTime(seconds,m,h,d));
return SendClientMessage(playerid, yellow, Jstring);
}
else return ShowMessage(playerid, red, 2);
}
case 2:
{
new id, WeapName[32], slot, weap, ammo, model , Float:Health , Float:Armour,Float:Vheath,Count = 0;
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
GetPlayerArmour(id,Armour);
GetPlayerHealth(id,Health);
format(Jstring, sizeof(Jstring), "__Informations for: %s(%d)__",GetName(id) ,id);
SendClientMessage(playerid, green, Jstring);
if(IsPlayerInAnyVehicle(id))
{
GetVehicleHealth(GetPlayerVehicleID(id), Vheath);
model = GetVehicleModel(GetPlayerVehicleID(id));
format(Jstring, sizeof(Jstring), "Health: %0.1f | Armour: %0.1f | Ratio: %0.2f | Ping: %d | Current vehicle: %s(Model: %d) | Vehicle health: %0.1f", Health , Armour, Float:pInfo[id][Kills]/Float:pInfo[id][Deaths],GetPlayerPing(id),VehicleNames[model-400],model,Vheath);
}
else
format(Jstring, sizeof(Jstring), "Health: %0.1f | Armour: %0.1f | Kills: %d | Deaths: %d |Ratio: %0.2f | Ping: %d", Health , Armour, pInfo[id][Kills],pInfo[id][Deaths], Float:pInfo[id][Kills]/Float:pInfo[id][Deaths],GetPlayerPing(id));
SendClientMessage(playerid, orange, Jstring);
for(slot = 0; slot < 13; slot++)
{
GetPlayerWeaponData(id, slot, weap, ammo);
if( ammo != 0 && weap != 0)
Count++;
}
if(Count == 0)
{
format(Jstring, sizeof(Jstring), "%s has no weapons!",GetName(id));
return SendClientMessage(playerid,green,Jstring);
}
else
{
format(Jstring, sizeof(Jstring), "__%s's weapons__",GetName(id));
SendClientMessage(playerid,red,Jstring);
}
if(Count >= 1)
{
for (slot = 0; slot < 13; slot++)
{
GetPlayerWeaponData(id, slot, weap, ammo);
if( ammo != 0 && weap != 0)
{
GetWeaponName(weap, WeapName, sizeof(WeapName));
format(Jstring,sizeof(Jstring),"%s (%d)", WeapName, ammo);
SendClientMessage(playerid, orange, Jstring);
}
}
}
return 1;
}
else return ShowMessage(playerid, red, 2);
}
case 3:
{
ShowPlayerDialog(playerid,JDIALOGS+46,DIALOG_STYLE_INPUT,"Report","Enter the reason:","Report","Close");
}
case 4:
{
if(pInfo[playerid][pLevel] >= 1)
{
new id,Float:P[3],Float:H,Float:A;
id = pInfo[playerid][Clicked];
if(!IsPlayerConnected(id) || playerid == id) return ShowMessage(playerid, red, 3);
#if SpecTextDraw == true
TextDrawShowForPlayer(playerid, SpecGTD);
PlayerTextDrawShow(playerid, SpecPTD);
UpdteSpecTD(playerid,id);
#endif
if (pInfo[playerid][Spec] == 0)
{
GetPlayerHealth(playerid, H);
GetPlayerArmour(playerid,A);
SetPVarInt(playerid,"Int",GetPlayerInterior(playerid));
SetPVarInt(playerid,"vworld",GetPlayerVirtualWorld(playerid));
GetPlayerPos(playerid,P[0],P[1],P[2]);
SetPVarFloat(playerid,"JX",P[0]);
SetPVarFloat(playerid,"JY",P[1]);
SetPVarFloat(playerid,"JZ",P[2]);
SetPVarFloat(playerid,"Health",H);
SetPVarFloat(playerid,"Armour",A);
StoreWeaponsData(playerid);
}
pInfo[playerid][Spec] = 1;
Specid[playerid] = id;
SetPlayerInterior(playerid,GetPlayerInterior(id));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
if (IsPlayerInAnyVehicle(id))
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
}
else
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, id);
}
SendClientMessage(playerid,lighterblue,"You are now spectating!");
}
}
case 5:
{
new id,Float:Pos[3];
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id) && id != playerid)
{
GetPlayerPos(id,Pos[0],Pos[1],Pos[2]);
SetPlayerInterior(playerid,GetPlayerInterior(id));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid),Pos[0]+3,Pos[1],Pos[2]);
LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(id));
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(id));
}
else SetPlayerPos(playerid,Pos[0]+3,Pos[1],Pos[2]);
format(Jstring,sizeof(Jstring),"You have been Teleported to '%s'", GetName(id));
SendClientMessage(playerid,yellow,Jstring);
return 1;
}
else return ShowMessage(playerid, red, 3);
}
case 6:
{
new id,Ffile[128],string[128];
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
strdel(aka,0,256);
CommandToAdmins(playerid,"aka");
GetPlayerIp(id,playerIP,16);
format(Ffile,sizeof(Ffile),"JLadmin/Logs/aka.ini");
INI_ParseFile(Ffile,"GetAkaLog");
format(Jstring,sizeof(Jstring),"__Player %s(ID: %d)'s Nick names__", GetName(id), id);
SendClientMessage(playerid,green,Jstring);
if(strlen(aka) > 70)
{
strmid(string,aka,0,75);
format(Jstring,sizeof(Jstring),"IP: %s - Nicks: %s", playerIP , string);
SendClientMessage(playerid,yellow,Jstring);
strmid(string,aka,75,sizeof(aka));
format(Jstring, sizeof(Jstring),"%s", string);
SendClientMessage(playerid,yellow,Jstring);
}
else
{
format(string,sizeof(string),"IP: %s - Nicks: %s", playerIP, aka);
SendClientMessage(playerid,yellow,string);
}
return 1;
}
else return ShowMessage(playerid, red, 2);
}
case 7:
{
new id;
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id) && id != playerid)
{
if(pInfo[id][Muted] == 1) return SendClientMessage(playerid,red,"This player is already muted. see /muted");
if(pInfo[playerid][pLevel] <= pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
format(Jstring,sizeof(Jstring),"Administrator %s has muted '%s'",GetName(playerid),GetName(id));
SendClientMessageToAll(red,Jstring);
pInfo[id][Muted] = 1;
return 1;
}
else return ShowMessage(playerid, red, 3);
}
case 8:
{
new id;
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
if(pInfo[id][Muted] == 0) return SendClientMessage(playerid,red,"This player is not muted muted");
format(Jstring,sizeof(Jstring),"You have unmuted '%s'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
format(Jstring,sizeof(Jstring),"Administrator %s has unmuted you!",GetName(playerid));
SendClientMessage(id,yellow,Jstring);
pInfo[id][Muted] = 0;
KillTimer(Mtimer[id]);
CommandToAdmins(playerid,"unmute");
return 1;
}
else return ShowMessage(playerid, red, 3);
}
case 9:
{
new id,ip[16], WeapName[32], slot, weap, ammo, model , seconds, Float:x,Float:y,Float:z, Float:Health ,Float:Ratio, Float:Armour,Float:Vheath,Count,Logg[5],Reg[5],pMuted[5],pJailed[5],pFrozen[5],Jfile[100],PlayerState[40],Seat[25];
id = pInfo[playerid][Clicked];
if(IsPlayerConnected(id))
{
GetPlayerArmour(id,Armour);
GetPlayerHealth(id,Health);
GetPlayerIp(id, ip, sizeof(ip));
GetPlayerPos(id,x,y,z);
seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs];
format(Jfile, sizeof(Jfile), ACCOUNTS_PATH, GetName(id));
if(fexist(Jfile))
INI_ParseFile(Jfile,"AccountsEditor");
else
{
RegisteredDate = "None"; RegisteredIP = "None"; LastSeen = "None";
}
if(pInfo[playerid][Deaths] > 0)
{
Ratio = Float:pInfo[id][Kills]/ Float:pInfo[id][Deaths];
}
else
{
Ratio = Float:pInfo[id][Kills]/ Float:pInfo[id][Deaths]+1;
}
if(pInfo[id][Registered] == 1) Reg = "Yes"; else Reg = "No";
if(pInfo[id][Logged] == 1) Logg = "Yes"; else Logg = "No";
if(pInfo[id][Muted] == 1) pMuted = "Yes"; else pMuted = "No";
if(pInfo[id][Jailed] == 1) pJailed = "Yes"; else pJailed = "No";
if(pInfo[id][Frozen] == 1) pFrozen = "Yes"; else pFrozen = "No";
if (IsPlayerConnected(id))
{
switch(pInfo[id][pLevel])
{
case 0: {
LevelName = "Player Stauts";
LevelColor = "{FFFFFF}";
}
case 1: {
LevelName = ADMIN_LEVEL_1;
LevelColor = LEVEL_1_COLOR;
}
case 2: {
LevelName = ADMIN_LEVEL_2;
LevelColor = LEVEL_2_COLOR;
}
case 3: {
LevelName = ADMIN_LEVEL_4;
LevelColor = LEVEL_3_COLOR;
}
case 4: {
LevelName = ADMIN_LEVEL_3;
LevelColor = LEVEL_4_COLOR;
}
case 5: {
LevelName = ADMIN_LEVEL_5;
LevelColor = LEVEL_5_COLOR;
}
default: {
LevelName = ADMIN_LEVEL_6;
LevelColor = LEVEL_6_COLOR;
}
}
switch(GetPlayerState(id))
{
case 0: {
PlayerState = "Empty (while initializing)";
}
case 1: {
PlayerState = "Player is on foot";
}
case 2: {
PlayerState = "Player is driver of a vehicle";
}
case 3: {
PlayerState = "Player is passenger of a vehicle";
}
case 4: {
PlayerState = "Player exits a vehicle";
}
case 5: {
PlayerState = "Player enters a vehicle as driver";
}
case 6: {
PlayerState = "Player enters a vehicle as passenger";
}
case 7: {
PlayerState = "Player is wasted or on class selection";
}
case 8: {
PlayerState = "Player is spawned";
}
case 9: {
PlayerState = "Player is spectating";
}
}
switch(GetPlayerVehicleSeat(id))
{
case 0: {
Seat = "Driver";
}
case 1: {
Seat = "Front Passenger";
}
case 2: {
Seat = "Back left passenger";
}
case 3: {
Seat = "Back right passenger";
}
case 4: {
Seat = "Passenger seats";
}
}
}
strdel(VLstring,0,850);
format(Jstring, sizeof(Jstring), "{0000FF}Nick name: %s (ID: %d) | IP: %s | Score: %d | Cash: $ %d | Kills: %d | Deaths: %d | Ratio: %0.1f\n\n",GetName(id) ,id,ip,GetPlayerScore(id),GetPlayerMoney(id),pInfo[id][Kills], pInfo[id][Deaths],Ratio);
strcat(VLstring, Jstring, sizeof(VLstring));
format(Jstring, sizeof(Jstring), "{0DF224}Health: %0.1f | Armour: %0.1f | Ping: %d | Admin level:%s %s (%d) | Donator Level(V.I.P): %d\n\n",Health ,Armour,GetPlayerPing(id),LevelColor,LevelName,pInfo[id][pLevel],pInfo[id][Donator],GetPlayerWantedLevel(id));
strcat(VLstring, Jstring, sizeof(VLstring));
format(Jstring, sizeof(Jstring), "{C837B9}Interior: %d | Virtual World: %d | Position: X = %0.3f, Y = %0.3f, Z = %0.3f | Skin: %d | Wanted Level: %d\n\n",GetPlayerInterior(id) ,GetPlayerVirtualWorld(id),x,y,z,GetPlayerSkin(id),GetPlayerWantedLevel(id));
strcat(VLstring, Jstring, sizeof(VLstring));
format(Jstring, sizeof(Jstring), "{F79709}Registered: %s | Logged: %s | Muted: %s | Jailed: %s | Frozen: %s | Last seen: %s\n\n",Reg ,Logg,pMuted,pJailed,pFrozen,LastSeen);
strcat(VLstring, Jstring, sizeof(VLstring));
format(Jstring, sizeof(Jstring), "{59A661}Registered Date: %s | Registered IP: %s | Time spent: %s\n\n",RegisteredDate ,RegisteredIP,ConvertTime(seconds,slot,weap,ammo));
strcat(VLstring, Jstring, sizeof(VLstring));
if(IsPlayerInAnyVehicle(id))
{
GetVehicleHealth(GetPlayerVehicleID(id), Vheath);
model = GetVehicleModel(GetPlayerVehicleID(id));
format(Jstring, sizeof(Jstring), "{FFFF80}Current vehicle: %s (Model ID: %d) | Vehicle health: %0.1f | Seat: %s\n\n", VehicleNames[model-400],model,Vheath,Seat);
strcat(VLstring, Jstring, sizeof(VLstring));
}
for(slot = 0; slot < 13; slot++)
{
GetPlayerWeaponData(id, slot, weap, ammo);
if( ammo != 0 && weap != 0)
Count++;
}
if(Count >= 1)
{
format(Jstring, sizeof(Jstring), "{FF0000}Player weapons: ",GetName(id));
strcat(VLstring, Jstring, sizeof(VLstring));
for (slot = 0; slot < 13; slot++)
{
GetPlayerWeaponData(id, slot, weap, ammo);
if( ammo != 0 && weap != 0)
{
GetWeaponName(weap, WeapName, sizeof(WeapName));
format(Jstring,sizeof(Jstring),"| %s (%d) ", WeapName, ammo);
strcat(VLstring, Jstring, sizeof(VLstring));
}
}
}
format(Jstring, sizeof(Jstring), "\n\nPlayer state: %s", PlayerState);
strcat(VLstring, Jstring, sizeof(VLstring));
ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX," {FB0404}Player Informations", VLstring, "Ok", "");
strdel(VLstring,0,850);
return 1;
}
else return ShowMessage(playerid, red, 2);
}
case 10:
{
return ShowPlayerDialog(playerid,JDIALOGS+117,DIALOG_STYLE_INPUT,"Warn","Enter the reason:","Kick","Cancel");
}
case 11:
{
return ShowPlayerDialog(playerid,JDIALOGS+47,DIALOG_STYLE_INPUT,"Kick Player","Enter the reason:","Kick","Cancel");
}
case 12:
{
return ShowPlayerDialog(playerid,JDIALOGS+48,DIALOG_STYLE_INPUT,"Ban Player","Enter the reason:","Ban","Cancel");
}
}
}
}
new string[128],NickName[24],Jfile[100];
if(dialogid == JDIALOGS+7)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Rename", NickName);
ShowPlayerDialog(playerid,JDIALOGS+110,DIALOG_STYLE_INPUT,"Rename Account","Enter the new nick name:","Change","Back");
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Registered Date", NickName);
format(string, 128, "Player Registered on %s", RegisteredDate);
ShowPlayerDialog(playerid,JDIALOGS+9,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 2:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Registered IP", NickName);
format(string, 128, "Player Registered with IP: %s", RegisteredIP);
ShowPlayerDialog(playerid,JDIALOGS+10,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 3:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Last logged IP", NickName);
format(string, 128, "Player last time used(logged in) IP: %s", LastLoggedIP);
ShowPlayerDialog(playerid,JDIALOGS+11,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 4:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Change level", NickName);
ShowPlayerDialog(playerid,JDIALOGS+12,DIALOG_STYLE_LIST,Jstring,"Level 0\n"LEVEL_1_COLOR"Level 1\n"LEVEL_2_COLOR"Level 2\n"LEVEL_3_COLOR"Level 3\n"LEVEL_4_COLOR"Level 4\n"LEVEL_5_COLOR"Level 5\n{FF0000}>>Enter level","Select","Back");
}
case 5:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Donator level", NickName);
ShowPlayerDialog(playerid,JDIALOGS+13,DIALOG_STYLE_LIST,Jstring,"Donator(V.I.P) Level 0\nDonator(V.I.P) Level 1\nDonator(V.I.P) Level 2\nDonator(V.I.P) Level 3","Select","Back");
}
case 6:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Ban/Unban", NickName);
ShowPlayerDialog(playerid,JDIALOGS+14,DIALOG_STYLE_LIST,Jstring,"{0000FF}UNBAN\n{FF0000}BAN","Select","Back");
}
case 7:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Mute/Unmute level", NickName);
ShowPlayerDialog(playerid,JDIALOGS+15,DIALOG_STYLE_LIST,Jstring,"{0000FF}Unmute\n{FF0000}Mute","Select","Back");
}
case 8:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Score", NickName);
ShowPlayerDialog(playerid,JDIALOGS+16,DIALOG_STYLE_INPUT,Jstring,"Enter new Score:","Done","Back");
}
case 9:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Cash", NickName);
ShowPlayerDialog(playerid,JDIALOGS+17,DIALOG_STYLE_INPUT,Jstring,"Enter new Cash:","Done","Back");
}
case 10:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Kills", NickName);
ShowPlayerDialog(playerid,JDIALOGS+18,DIALOG_STYLE_INPUT,Jstring,"Enter new Kills:","Done","Back");
}
case 11:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Kills", NickName);
ShowPlayerDialog(playerid,JDIALOGS+19,DIALOG_STYLE_INPUT,Jstring,"Enter new Deaths:","Done","Back");
}
case 12:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Ratio", NickName);
format(string, 128, "Player Kills: %d\nPlayer deaths: %d\nPlayer Ratio: %0.2f", AccKills,AccDeaths,Float:AccKills/Float:AccDeaths);
ShowPlayerDialog(playerid,JDIALOGS+20,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 13:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Favorite skin", NickName);
format(string, 128, "Player favorite Skin is %d", AccSkin);
ShowPlayerDialog(playerid,JDIALOGS+21,DIALOG_STYLE_MSGBOX,Jstring,string,"Edit","Back");
}
case 14:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Auto login", NickName);
ShowPlayerDialog(playerid,JDIALOGS+22,DIALOG_STYLE_LIST,Jstring,"{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 15:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: total played secs", NickName);
format(string, 128, "Player total played seconds: %d\n{FF0000}*Not recommend to edit.", AccTotalSecs);
ShowPlayerDialog(playerid,JDIALOGS+23,DIALOG_STYLE_MSGBOX,Jstring,string,"Edit","Back");
}
case 16:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Last seen", NickName);
format(string, 128, "Last seen on %s", LastSeen);
ShowPlayerDialog(playerid,JDIALOGS+24,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 17:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
INI_ParseFile(Jfile,"AccountsEditor");
format(Jstring, 128, "%s: Total Spent time", NickName);
format(string, 128, "Player Total ingame spent time: %s", AccPlayedTime);
ShowPlayerDialog(playerid,JDIALOGS+25,DIALOG_STYLE_MSGBOX,Jstring,string,"Back","");
}
case 18:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: PassWord", NickName);
ShowPlayerDialog(playerid,JDIALOGS+109,DIALOG_STYLE_INPUT,Jstring,"Enter the new password:","Change","Back");
}
}
}
}
if(dialogid == JDIALOGS+9)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+10)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+11)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+12)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 0);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 1);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 2:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 2);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 3:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 3);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 4:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 4);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 5:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", 5);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 6:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Change level", NickName);
ShowPlayerDialog(playerid,JDIALOGS+26,DIALOG_STYLE_INPUT,Jstring,"{FF0000}Enter new level:","Change","Back");
}
}
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+13)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Donator", 0);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Donator", 1);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 2:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Donator", 2);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 3:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Donator", 3);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
}
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+14)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Banned", 0);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Banned", 1);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
}
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+15)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Muted", 0);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Muted", 1);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
}
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+16)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Score", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+16,DIALOG_STYLE_INPUT,Jstring,"Enter new Score:\n{FF0000}*Score must be a nemeric value","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Score", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+17)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Cash", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+17,DIALOG_STYLE_INPUT,Jstring,"Enter new Cash:\n{FF0000}*Cash must be a nemeric value","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Cash", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+18)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Kills", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+18,DIALOG_STYLE_INPUT,Jstring,"Enter new Kills:\n{FF0000}*Kills must be a nemeric value","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Kills", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+19)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Death", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+19,DIALOG_STYLE_INPUT,Jstring,"Enter new Deaths:\n{FF0000}*Deaths must be a nemeric value","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Deaths", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+20)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+21)
{
if(response)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Change skin", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+27,DIALOG_STYLE_INPUT,Jstring,"Enter new skinID:","Save","Back");
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+27)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0 || strval(inputtext) < 0 || strval(inputtext) > 299)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Change skin", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+27,DIALOG_STYLE_INPUT,Jstring,"Enter new skinID:\n{FF0000}*Please enter a valid SkinID (0 - 299)","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Skin", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+22)
{
if(response)
{
switch(listitem)
{
case 0:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Autologin", 1);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
case 1:
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Autologin", 0);
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
}
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+23)
{
if(response)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Total Played Seconds", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+28,DIALOG_STYLE_INPUT,Jstring,"Enter new played seconds:","Save","Back");
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+28)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Total Played Seconds", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+28,DIALOG_STYLE_INPUT,Jstring,"Enter new played seconds:\n{FF0000}Seconds must be a nemeric value","Save","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "TotalSeconds", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+109)
{
if(response)
{
if(strlen(inputtext) < 3)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: PassWord", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+109,DIALOG_STYLE_INPUT,Jstring,"Enter the new Password:\n{FF0000}*Password lenght must be between 3 - 20 chracters","Change","Back");
}
new buf[145];
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
WP_Hash(buf, sizeof(buf), inputtext);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteString(ACCOUNT, "Password", buf);
INI_Close(ACCOUNT);
format(Jstring, sizeof(Jstring),"You have changed %s's password to '%s'",NickName,inputtext);
SendClientMessage(playerid,yellow,Jstring);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+110)
{
if(response)
{
if(strlen(inputtext) < 3 || strlen(inputtext) > MAX_PLAYER_NAME)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: PassWord", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+110,DIALOG_STYLE_INPUT,"Rename Account","Enter the new nick name:\n{FF0000}*Name lenght must be between 3 - 20 chracters","Change","Back");
}
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, inputtext);
if(fexist(Jfile)) return SendClientMessage(playerid,red,"Error: You entered nick name is already in use, please try something else!");
if(InvalidNick(inputtext)) return SendClientMessage(playerid,red,"Unacceptable NickName. Please only use (0-9, a-z, [], (), $, @, ., _ and =)");
format(Jstring, sizeof(Jstring),"You have changed Account %s name to '%s'",NickName,inputtext);
SendClientMessage(playerid,yellow,Jstring);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
JLrename(Jfile,inputtext);
SetPVarString(playerid,"AccountName",inputtext);
foreach(Player, i)
{
if(strcmp(NickName,GetName(i),true) == 0)
{
format(Jstring, sizeof(Jstring),"Admin '%s' has renamed your account name to '%s'",GetName(playerid),inputtext);
SendClientMessage(i,yellow,Jstring);
SetPlayerName(i,inputtext);
}
}
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+24)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+25)
{
if(response)
{
return AccountEditor(playerid);
}
}
if(dialogid == JDIALOGS+26)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0)
{
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jstring, 128, "%s: Change level", NickName);
return ShowPlayerDialog(playerid,JDIALOGS+26,DIALOG_STYLE_INPUT,Jstring,"Enter new Level:\n{FF0000}*Level must be a nemeric value","Save","Back");
}
format(Jstring, 128, "%s: Change level", NickName);
format(string, 128, "Enter new Level:\n{FF0000}*Error: Server maximum admin level is %d", MaxAdminLevel);
if(strval(inputtext) > MaxAdminLevel) return ShowPlayerDialog(playerid,JDIALOGS+26,DIALOG_STYLE_INPUT,Jstring,string,"Save","Back");
GetPVarString(playerid, "AccountName", NickName, 24);
format(Jfile, 100, ACCOUNTS_PATH, NickName);
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", strval(inputtext));
INI_Close(ACCOUNT);
return AccountEditor(playerid);
}
else return AccountEditor(playerid);
}
if(dialogid == JDIALOGS+38)
{
if(response)
{
switch(listitem)
{
case 0:
{
return ShowPlayerDialog(playerid,JDIALOGS+39,DIALOG_STYLE_MSGBOX,"Clear ban log","Are you sure you want to clear the ban log ?","Yes","No");
}
case 1:
{
return ShowPlayerDialog(playerid,JDIALOGS+40,DIALOG_STYLE_MSGBOX,"Clear kick log","Are you sure you want to clear the kick log ?","Yes","No");
}
case 2:
{
return ShowPlayerDialog(playerid,JDIALOGS+41,DIALOG_STYLE_MSGBOX,"Clear AC log","Are you sure you want to clear the anti cheats records ?","Yes","No");
}
case 3:
{
return ShowPlayerDialog(playerid,JDIALOGS+42,DIALOG_STYLE_MSGBOX,"Clear PM(s) log","Are you sure you want to clear the private messages log ?","Yes","No");
}
case 4:
{
return ShowPlayerDialog(playerid,JDIALOGS+43,DIALOG_STYLE_MSGBOX,"Clear Crash log","Are you sure you want to clear the crash log ?","Yes","No");
}
}
}
}
if(dialogid == JDIALOGS+39)
{
if(response)
{
format(Jfile, 100, LOGS_PATH, "Bans");
if(!fexist(Jfile)) return ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Error","{FF0000}Could not clear the ban log (Could not find the file)","Ok","");
fremove(Jfile);
ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Ban log cleared","You have successfully cleared the ban log","Ok","");
}
}
if(dialogid == JDIALOGS+40)
{
if(response)
{
format(Jfile, 100, LOGS_PATH, "KickLog");
if(!fexist(Jfile)) return ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Error","{FF0000}Could not clear the kick log(Could not find the file)","Ok","");
fremove(Jfile);
ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Kick log cleared","You have successfully cleared the kick log","Ok","");
}
}
if(dialogid == JDIALOGS+41)
{
if(response)
{
format(Jfile, 100, LOGS_PATH, "AntiCheatLog");
if(!fexist(Jfile)) return ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Error","{FF0000}Could not clear the anti cheat log(Could not find the file)","Ok","");
fremove(Jfile);
ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"AC log cleared","You have successfully cleared the anti cheat log","Ok","");
}
}
if(dialogid == JDIALOGS+42)
{
if(response)
{
format(Jfile, 100, LOGS_PATH, "PrivateMessages");
if(!fexist(Jfile)) return ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Error","{FF0000}Could not clear the private messages log(Could not find the file)","Ok","");
fremove(Jfile);
ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"PM(s) log cleared","You have successfully cleared the private message log","Ok","");
}
}
if(dialogid == JDIALOGS+43)
{
if(response)
{
format(Jfile, 100, LOGS_PATH, "Crash");
if(!fexist(Jfile)) return ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Error","{FF0000}Could not clear the crash log(Could not find the file)","Ok","");
fremove(Jfile);
ShowPlayerDialog(playerid,JDIALOGS+44,DIALOG_STYLE_MSGBOX,"Crash log cleared","You have successfully cleared the crash log","Ok","");
}
}
if(dialogid == JDIALOGS+46)
{
if(response)
{
new id = pInfo[playerid][Clicked];
if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
if(strlen(inputtext) < 2 || strlen(inputtext) > 80) return ShowPlayerDialog(playerid,JDIALOGS+46,DIALOG_STYLE_INPUT,"Report","Enter the reason:\n{FF0000}*Please enter a valid reason","Report","Close");
format(Jstring,sizeof(Jstring),"{FF0000}[REPORT:]{FFFFFF} %s(ID: %d) Reported %s(ID: %d) |{FF0000} REASON: %s",GetName(playerid),playerid,GetName(id),id,inputtext);
SendToAdmins(-1,Jstring);
format(Jstring,sizeof(Jstring),"%s Has Reported %s | REASON: %s",GetName(playerid),GetName(id),inputtext);
WriteToLog(Jstring,"Reports");
StoreReport(playerid,id,inputtext);
}
}
if(dialogid == JDIALOGS+47)
{
if(response)
{
if(pInfo[playerid][pLevel] >= 1)
{
new id;
id = pInfo[playerid][Clicked];
if(strlen(inputtext) < 2 || strlen(inputtext) > 80) return ShowPlayerDialog(playerid,JDIALOGS+47,DIALOG_STYLE_INPUT,"Kick Player","Enter the reason:\n{FF0000}*Please enter a valid reason","Kick","Cancel");
if(IsPlayerConnected(id) && id != playerid)
{
if(pInfo[playerid][pLevel] <= pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
format(Jstring,sizeof(Jstring),"'%s' has been kicked by administrator %s Reason: %s",GetName(id),GetName(playerid),inputtext);
SendClientMessageToAll(red,Jstring);
format(Jstring,sizeof(Jstring),"[INGAME KICK] %s has kicked %s - %s ",GetName(playerid),GetName(id),inputtext);
WriteToLog(Jstring,"KickLog");
return SetTimerEx("KickPlayer",200,false,"d", id);
}
else return ShowMessage(playerid, red, 3);
}
else return ShowMessage(playerid, red, 1);
}
}
if(dialogid == JDIALOGS+48)
{
if(response)
{
if(pInfo[playerid][pLevel] >= 2)
{
new id, file[200];
new year, month, day, hour, minuite, second;
id = pInfo[playerid][Clicked];
if(strlen(inputtext) < 2 || strlen(inputtext) > 80) return ShowPlayerDialog(playerid,JDIALOGS+48,DIALOG_STYLE_INPUT,"Ban Player","Enter the reason:\n{FF0000}*Please enter a valid reason","Ban","Cancel");
if(IsPlayerConnected(id) && id != playerid)
{
if(pInfo[playerid][pLevel] <= pInfo[id][pLevel]) return ShowMessage(playerid, red, 6);
getdate(year, month, day);
gettime(hour,minuite,second);
format(Jstring,sizeof(Jstring),"%s has been Banned by Administrator %s | Reason: %s <Date: %d/%d/%d> <Time: %d:%d>",GetName(id),GetName(playerid),inputtext,day,month,year,hour,minuite);
SendClientMessageToAll(red,Jstring);
format(JLstring,sizeof(JLstring),"{37C8C8}Administrator %s has banned you for: \"%s\"\n\nVisit "WEBSITE" for more informations", GetName(playerid),inputtext);
ShowPlayerDialog(id,JDIALOGS+200,DIALOG_STYLE_MSGBOX," {FF0000}You are BANNED",JLstring,"OK","");
if(pInfo[id][Logged] == 1)
{
format(file, 200, ACCOUNTS_PATH, GetName(id));
new INI:ACCOUNT = INI_Open(file);
INI_WriteInt(ACCOUNT, "Banned", 1);
INI_Close(ACCOUNT);
}
format(Jstring,sizeof(Jstring),"Ban by %s Reason: %s",GetName(playerid),inputtext);
SetPVarString(id,"Banreason",Jstring);
format(Jstring,sizeof(Jstring),"[INGAME BAN] %s has banned %s - %s",GetName(playerid),GetName(id),inputtext);
WriteToLog(Jstring,"Bans");
return SetTimerEx("BanPlayer",200,false,"dd", id,0);
}
else return ShowMessage(playerid, red, 3);
}
return 1;
}
}
if(dialogid == JDIALOGS+29)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(IsDisabledChat == 0) return SendClientMessage(playerid,red,"Main chat is not disabled!");
format(Jstring,sizeof(Jstring),"Admin %s has enabled the main chat",GetName(playerid));
SendClientMessageToAll(orange,Jstring);
IsDisabledChat = 0;
}
case 1:
{
if(IsDisabledChat == 1) return SendClientMessage(playerid,red,"Main chat is already disabled!");
format(Jstring,sizeof(Jstring),"Admin %s has disabled the main chat",GetName(playerid));
SendClientMessageToAll(orange,Jstring);
AdmName = GetName(playerid);
IsDisabledChat = 1;
}
}
}
}
if(dialogid == JDIALOGS+50)
{
if(response)
{
if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have a vehicle already");
switch(listitem)
{
case 0:
{
new vid;
GiveVehicle(playerid,558);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1089); AddVehicleComponent(vid, 1163);
AddVehicleComponent(vid, 1085); AddVehicleComponent(vid, 1090); AddVehicleComponent(vid, 1165);
AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1091); AddVehicleComponent(vid, 1167);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,1);
}
case 1:
{
new vid;
GiveVehicle(playerid,560);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1033); AddVehicleComponent(vid, 1138);
AddVehicleComponent(vid, 1026); AddVehicleComponent(vid, 1083); AddVehicleComponent(vid, 1140);
AddVehicleComponent(vid, 1028); AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1169);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,1);
}
case 2:
{
new vid;
GiveVehicle(playerid,559);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1158);
AddVehicleComponent(vid, 1065); AddVehicleComponent(vid, 1085); AddVehicleComponent(vid, 1160);
AddVehicleComponent(vid, 1068); AddVehicleComponent(vid, 1069); AddVehicleComponent(vid, 1161);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,0);
}
case 3:
{
new vid;
GiveVehicle(playerid,561);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1061); AddVehicleComponent(vid, 1156);
AddVehicleComponent(vid, 1056); AddVehicleComponent(vid, 1064); AddVehicleComponent(vid, 1157);
AddVehicleComponent(vid, 1060); AddVehicleComponent(vid, 1074);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,1);
}
case 4:
{
new vid;
GiveVehicle(playerid,561);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1058); AddVehicleComponent(vid, 1087);
AddVehicleComponent(vid, 1055); AddVehicleComponent(vid, 1059); AddVehicleComponent(vid, 1154);
AddVehicleComponent(vid, 1056); AddVehicleComponent(vid, 1085); AddVehicleComponent(vid, 1155);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,2);
}
case 5:
{
new vid;
GiveVehicle(playerid,560);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1033); AddVehicleComponent(vid, 1140);
AddVehicleComponent(vid, 1029); AddVehicleComponent(vid, 1079); AddVehicleComponent(vid, 1169);
AddVehicleComponent(vid, 1031); AddVehicleComponent(vid, 1138);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,0);
}
case 6:
{
new vid;
GiveVehicle(playerid,562);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1039); AddVehicleComponent(vid, 1146);
AddVehicleComponent(vid, 1037); AddVehicleComponent(vid, 1079); AddVehicleComponent(vid, 1148);
AddVehicleComponent(vid, 1038); AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1172);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,1);
}
case 7:
{
new vid;
GiveVehicle(playerid,565);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1050); AddVehicleComponent(vid, 1087);
AddVehicleComponent(vid, 1045); AddVehicleComponent(vid, 1054); AddVehicleComponent(vid, 1151);
AddVehicleComponent(vid, 1047); AddVehicleComponent(vid, 1083); AddVehicleComponent(vid, 1153);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,0);
}
case 8:
{
new vid;
GiveVehicle(playerid,534);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1100);
AddVehicleComponent(vid, 1077); AddVehicleComponent(vid, 1122);
AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1127);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,2);
}
case 9:
{
new vid;
GiveVehicle(playerid,535);
vid = GetPlayerVehicleID(playerid);
AddVehicleComponent(vid, 1010); AddVehicleComponent(vid, 1109); AddVehicleComponent(vid, 1118);
AddVehicleComponent(vid, 1087); AddVehicleComponent(vid, 1113);
AddVehicleComponent(vid, 1098); AddVehicleComponent(vid, 1115);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
ChangeVehiclePaintjob(vid,0);
}
}
}
}
if(dialogid == JDIALOGS+51)
{
if(response)
{
new id = GetPVarInt(playerid, "TargetID");
switch(listitem)
{
case 0:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'yellow'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,yellow);
}
}
case 1:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'white'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,white);
}
}
case 2:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'blue'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,blue);
}
}
case 3:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'red'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,red);
}
}
case 4:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'green'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,green);
}
}
case 5:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'orange'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,orange);
}
}
case 6:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'purple'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,purple);
}
}
case 7:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'PINK'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,pink);
}
}
case 8:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'BROWN'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,brown);
}
}
case 9:
{
format(Jstring,sizeof(Jstring),"You have set %s' maker colour to 'BLACK'",GetName(id));
SendClientMessage(playerid,yellow,Jstring);
foreach(Player, i)
{
SetPlayerMarkerForPlayer(i,id,black);
}
}
}
}
}
if(dialogid == JDIALOGS+52)
{
if(response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid,JDIALOGS+53,DIALOG_STYLE_LIST,"SERVER AUTO LOGIN","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 1:
{
ShowPlayerDialog(playerid,JDIALOGS+54,DIALOG_STYLE_LIST,"DETECT PAUSE","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 2:
{
ShowPlayerDialog(playerid,JDIALOGS+55,DIALOG_STYLE_LIST,"MUST REGISTER","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 3:
{
ShowPlayerDialog(playerid,JDIALOGS+56,DIALOG_STYLE_INPUT,"SERVER MAX PING ALLOWED","Please enter the server new max ping","Ok","Back");
}
case 4:
{
ShowPlayerDialog(playerid,JDIALOGS+57,DIALOG_STYLE_LIST,"ANTI SPAM","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 5:
{
ShowPlayerDialog(playerid,JDIALOGS+58,DIALOG_STYLE_LIST,"ANTI WEAPON HACK","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 6:
{
ShowPlayerDialog(playerid,JDIALOGS+59,DIALOG_STYLE_LIST,"ANTI BAD WORDS","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 7:
{
ShowPlayerDialog(playerid,JDIALOGS+60,DIALOG_STYLE_LIST,"FORBIDDEN NAMES KICK","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 8:
{
ShowPlayerDialog(playerid,JDIALOGS+61,DIALOG_STYLE_LIST,"FORBIDDEN PART NAMES KICK","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 9:
{
ShowPlayerDialog(playerid,JDIALOGS+62,DIALOG_STYLE_LIST,"ANTI ADVERTISEMENTS","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 10:
{
ShowPlayerDialog(playerid,JDIALOGS+63,DIALOG_STYLE_LIST,"ANTI BAN EVADE","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 11:
{
ShowPlayerDialog(playerid,JDIALOGS+64,DIALOG_STYLE_INPUT,"MAX ADMIN LEVEL","Please enter the new max admin level","Ok","Back");
}
case 12:
{
ShowPlayerDialog(playerid,JDIALOGS+65,DIALOG_STYLE_LIST,"ADMIN IMMUNITY","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 13:
{
ShowPlayerDialog(playerid,JDIALOGS+66,DIALOG_STYLE_LIST,"ADMIN READ PM(S)","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 14:
{
ShowPlayerDialog(playerid,JDIALOGS+67,DIALOG_STYLE_LIST,"ADMIN READ CMDS","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 15:
{
ShowPlayerDialog(playerid,JDIALOGS+68,DIALOG_STYLE_LIST,"PM DIALOG","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 16:
{
ShowPlayerDialog(playerid,JDIALOGS+69,DIALOG_STYLE_LIST,"ADMIN CHEAT BANS","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 17:
{
ShowPlayerDialog(playerid,JDIALOGS+70,DIALOG_STYLE_LIST,"ALLOW CHANGE NICK","{0000FF}Enable\n{FF0000}Disable","Select","Back");
}
case 18:
{
ShowPlayerDialog(playerid,JDIALOGS+71,DIALOG_STYLE_LIST,"FORBIDDEN WEAPON","View Forbidden weapons list\nAdd new weapon\nClear Forbidden weapons list","Select","Back");
}
case 19:
{
ShowPlayerDialog(playerid,JDIALOGS+76,DIALOG_STYLE_LIST,"FORBIDDEN NAMES","View Forbidden names list\nAdd new forbidden name\nClear Forbidden names list","Select","Back");
}
case 20:
{
ShowPlayerDialog(playerid,JDIALOGS+79,DIALOG_STYLE_LIST,"FORBIDDEN PART NAMES","View Forbidden Part Nick list\nAdd new forbidden nick part\nClear Forbidden part nicks list","Select","Back");
}
case 21:
{
ShowPlayerDialog(playerid,JDIALOGS+82,DIALOG_STYLE_LIST,"BAD WORDS","View bad word list\nAdd new bad word\nClear bad word list","Select","Back");
}
case 22:
{
LoadSettings();
LoadIllegalWeaps();
LoadForbiddenNicks();
LoadBadNickParts();
LoadBadWords();
LoadTeleports();
SendClientMessage( playerid, yellow, "You have re-loaded JLadmin system settings!" );
}
}
}
}
if(dialogid == JDIALOGS+53)
{
if(response)
{
switch(listitem)
{
case 0:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "AutoLogin", 1);
INI_Close(SETTING);
AutoLogin = 1;
return ServSettings(playerid);
}
case 1:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "AutoLogin", 0);
INI_Close(SETTING);
AutoLogin = 0;
return ServSettings(playerid);
}
}
}
else return ServSettings(playerid);
}
if(dialogid == JDIALOGS+54)
{
if(response)
{
switch(listitem)
{
case 0:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "DetectPausers", 1);
INI_Close(SETTING);
DetectPausers = 1;
return ServSettings(playerid);
}
case 1:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "DetectPausers", 0);
INI_Close(SETTING);
DetectPausers = 0;
return ServSettings(playerid);
}
}
}
else return ServSettings(playerid);
}
if(dialogid == JDIALOGS+55)
{
if(response)
{
switch(listitem)
{
case 0:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "MustRegister", 1);
INI_Close(SETTING);
MustRegister = 1;
return ServSettings(playerid);
}
case 1:
{
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "MustRegister", 0);
INI_Close(SETTING);
MustRegister = 0;
return ServSettings(playerid);
}
}
}
else return ServSettings(playerid);
}
if(dialogid == JDIALOGS+56)
{
if(response)
{
if(!IsNumeric(inputtext) || strlen(inputtext) == 0 || strval(inputtext) < 0)
return ShowPlayerDialog(playerid,JDIALOGS+56,DIALOG_STYLE_INPUT,"SERVER MAX PING ALLOWED","Enter the server new max ping\n{FF0000}*Please enter a Numeric value","Save","Back");
format(Jfile,sizeof(Jfile),"JLadmin/Settings/settings.cfg");
new INI:SETTING = INI_Open(Jfile);
INI_WriteInt(SETTING, "MaxPing", strval(inputtext));
INI_Close(SETTING);
MaxPing = strval(inputtext);
return ServSettings(playerid);
}
else return ServSettings(playerid);
}
Code:
// Make sure you don't get warnings about tabsize
#pragma tabsize 0
// Include default files
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <streamer>
// ******************************************************************************************************************************
// Settings that can be changed
// ******************************************************************************************************************************
// Default max number of players is set to 500, re-define it to 50
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
// Define housing parameters
#define MAX_BUSINESS 500 // Defines the maximum number of businesses that can be created
#define MAX_BUSINESSPERPLAYER 20 // Defines the maximum number of businesses that any player can own (useable values: 1 to 20)
// Define path to business-files
#define BusinessFile "PPC_Business/Business%i.ini"
#define BusinessTimeFile "PPC_Business/BusinessTime.ini"
// Set the exit-time for exiting a business (required if you use custom-made islands, otherwise you'll fall into the water)
// Default: 1 second (1000 milliseconds)
new ExitBusinessTimer = 1000;
// Define Dialogs
#define DialogCreateBusSelType 2001
#define DialogBusinessNameChange 2002
#define DialogSellBusiness 2003
#define DialogBusinessMenu 2004
#define DialogGoBusiness 2005
// ******************************************************************************************************************************
// Enums and the array-setups that use them
// ******************************************************************************************************************************
// Setup a custom type that holds all data for businesses
enum TBusinessData
{
PickupID, // Holds the pickup-id that is linked to this business
Text3D:DoorText, // Holds the reference to the 3DText above the business's pickup
MapIconID, // Holds the ID of the mapicon for the business
BusinessName[100], // Holds the name of the business (this will be displayed above the pickup near the business when it's owned)
Float:BusinessX, // Holds the X-coordinate of the pickup for the Business
Float:BusinessY, // Holds the Y-coordinate of the pickup for the Business
Float:BusinessZ, // Holds the Z-coordinate of the pickup for the Business
BusinessType, // Holds the type of business (well stacked pizza, burger shot, ...), this defines which icon and interior to use
BusinessLevel, // Holds the level of upgrades the business has
LastTransaction, // Holds the amount of minutes when the last transaction took place (buying the business or retrieving the money by the owner)
bool:Owned, // Holds true if the Business is owned by somebody
Owner[24] // Holds the name of the owner of the Business
}
// Holds the data for all houses
new ABusinessData[MAX_BUSINESS][TBusinessData];
// This variable holds the business-time (this value is increased every hour and is used to calculate the amount of money a business
// has generated after the last transaction of the business)
new BusinessTransactionTime;
// Setup a custom type that holds all data about a business
enum TBusinessType
{
InteriorName[50], // Holds the name of the interior
InteriorID, // Holds the interior-id
Float:IntX, // Holds the X-coordinate of the spawn-location where you enter the business
Float:IntY, // Holds the Y-coordinate of the spawn-location where you enter the business
Float:IntZ, // Holds the Z-coordinate of the spawn-location where you enter the business
BusPrice, // Holds the price for the business
BusEarnings, // Holds the earnings for this type of business (a business earns this money every minute even when the player is offline)
// The earnings may not seem that high, but earning $5 every minute will earn you $7200 every day, even when you're offline
// These are multiplied by the level of your business, so a level 5 business earns you $36000 every day
// Using the default buying prices, you'll need about 70 days to refund your business and start making money with it
IconID // Holds the icon-id which represents the business
}
// Holds the data for all interiors for businesses
new ABusinessInteriors[][TBusinessType] =
{
{"Dummy", 0, 0.0, 0.0, 0.0, 0, 0, 0}, // Dummy business (Type 0), never used
{"24/7 (Small)", 6, -26.75, -55.75, 1003.6, 500000, 5, 52}, // Type 1 (earnings per day: $7200)
{"24/7 (Medium)", 18, -31.0, -89.5, 1003.6, 700000, 7, 52}, // Type 2 (earnings per day: $10080)
{"Bar", 11, 502.25, -69.75, 998.8, 400000, 4, 49}, // Type 3 (earnings per day: $5760)
{"Barber (Small)", 2, 411.5, -21.25, 1001.8, 300000, 3, 7}, // Type 4 (earnings per day: $4320)
{"Barber (Medium)", 3, 418.75, -82.5, 1001.8, 400000, 4, 7}, // Type 5 (earnings per day: $5760)
{"Betting shop", 3, 833.25, 7.0, 1004.2, 1500000, 15, 52}, // Type 6 (earnings per day: $21600)
{"Burger Shot", 10, 363.5, -74.5, 1001.5, 700000, 7, 10}, // Type 7 (earnings per day: $10080)
{"Casino (4 Dragons)", 10, 2017.25, 1017.75, 996.9, 2500000, 25, 44}, // Type 8 (earnings per day: $36000)
{"Casino (Caligula's)", 1, 2234.0, 1710.75, 1011.3, 2500000, 25, 25}, // Type 9 (earnings per day: $36000)
{"Casino (Small)", 12, 1133.0, -9.5, 1000.7, 2000000, 20, 43}, // Type 10 (earnings per day: $28800)
{"Clothing (Binco)", 15, 207.75, -109.0, 1005.2, 800000, 8, 45}, // Type 11 (earnings per day: $11520)
{"Clothing (Pro)", 3, 207.0, -138.75, 1003.5, 800000, 8, 45}, // Type 12 (earnings per day: $11520)
{"Clothing (Urban)", 1, 203.75, -48.5, 1001.8, 800000, 8, 45}, // Type 13 (earnings per day: $11520)
{"Clothing (Victim)", 5, 226.25, -7.5, 1002.3, 800000, 8, 45}, // Type 14 (earnings per day: $11520)
{"Clothing (ZIP)", 18, 161.5, -92.25, 1001.8, 800000, 8, 45}, // Type 15 (earnings per day: $11520)
{"Cluckin' Bell", 9, 365.75, -10.75, 1001.9, 700000, 7, 14}, // Type 16 (earnings per day: $10080)
{"Disco (Small)", 17, 492.75, -22.0, 1000.7, 1000000, 10, 48}, // Type 17 (earnings per day: $14400)
{"Disco (Large)", 3, -2642.0, 1406.5, 906.5, 1200000, 12, 48}, // Type 18 (earnings per day: $17280)
{"Gym (LS)", 5, 772.0, -3.0, 1000.8, 500000, 5, 54}, // Type 19 (earnings per day: $7200)
{"Gym (SF)", 6, 774.25, -49.0, 1000.6, 500000, 5, 54}, // Type 20 (earnings per day: $7200)
{"Gym (LV)", 7, 774.25, -74.0, 1000.7, 500000, 5, 54}, // Type 21 (earnings per day: $7200)
{"Motel", 15, 2216.25, -1150.5, 1025.8, 1000000, 10, 37}, // Type 22 (earnings per day: $14400)
{"RC shop", 6, -2238.75, 131.0, 1035.5, 600000, 6, 46}, // Type 23 (earnings per day: $8640)
{"Sex-shop", 3, -100.25, -22.75, 1000.8, 800000, 8, 38}, // Type 24 (earnings per day: $11520)
{"Slaughterhouse", 1, 933.75, 2151.0, 1011.1, 500000, 5, 50}, // Type 25 (earnings per day: $7200)
{"Stadium (Bloodbowl)", 15, -1394.25, 987.5, 1024.0, 1700000, 17, 33}, // Type 26 (earnings per day: $24480)
{"Stadium (Kickstart)", 14, -1410.75, 1591.25, 1052.6, 1700000, 17, 33}, // Type 27 (earnings per day: $24480)
{"Stadium (8-Track)", 7, -1396.0, -208.25, 1051.2, 1700000, 17, 33}, // Type 28 (earnings per day: $24480)
{"Stadium (Dirt Bike)", 4, -1425.0, -664.5, 1059.9, 1700000, 17, 33}, // Type 29 (earnings per day: $24480)
{"Stripclub (Small)", 3, 1212.75, -30.0, 1001.0, 700000, 7, 48}, // Type 30 (earnings per day: $10080)
{"Stripclub (Large)", 2, 1204.75, -12.5, 1001.0, 900000, 9, 48}, // Type 31 (earnings per day: $12960)
{"Tattoo LS", 16, -203.0, -24.25, 1002.3, 500000, 5, 39}, // Type 32 (earnings per day: $7200)
{"Well Stacked Pizza", 5, 372.25, -131.50, 1001.5, 600000, 6, 29} // Type 33 (earnings per day: $8640)
};
// Setup all the fields required for the player data (Speedometer TextDraw, current job, ...)
enum TPlayerData
{
Business[20], // Holds the BusinessID's of the businesses that the player owns (index of the ABusinessData array), maximum 20 businesses per player
CurrentBusiness // Holds the BusinessID to track in which business the player currently is (used when accessing the businessmenu)
}
// Create an array to hold the playerdata for every player
new APlayerData[MAX_PLAYERS][TPlayerData];
// These variables are used when starting the script and debugging purposes
new TotalBusiness;
// ******************************************************************************************************************************
// Callbacks
// ******************************************************************************************************************************
// The main function (used only once when the server loads)
main()
{
}
// This callback gets called when the server initializes the filterscript
public OnFilterScriptInit()
{
// Load the businesstime-file (which holds the current time for the businesses, used for calculating the earnings every minute)
BusinessTime_Load();
// Loop through all businesses and try to load them (BusID 0 isn't used)
for (new BusID = 1; BusID < MAX_BUSINESS; BusID++)
BusinessFile_Load(BusID); // Try to load the business-file
// Start the businesstimer and run it every minute
SetTimer("Business_TransactionTimer", 1000 * 60, true);
// Print information about the filterscript on the server-console
printf("-------------------------------------");
printf("PPC Business filterscript initialized");
printf("Businesses loaded: %i", TotalBusiness);
printf("-------------------------------------");
return 1;
}
// This callback gets called when a player connects to the server
public OnPlayerConnect(playerid)
{
// Setup local variables
new BusID, BusSlot, Name[24];
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Loop through all businesses to find the ones which belong to this player
for (BusID = 1; BusID < MAX_BUSINESS; BusID++)
{
// Check if the business exists
if (IsValidDynamicPickup(ABusinessData[BusID][PickupID]))
{
// Check if the business is owned
if (ABusinessData[BusID][Owned] == true)
{
// Check if the player is the owner of the business
if (strcmp(ABusinessData[BusID][Owner], Name, false) == 0)
{
// Add the BusID to the player's account for faster reference later on
APlayerData[playerid][Business][BusSlot] = BusID;
// Select the next BusSlot
BusSlot++;
}
}
}
}
return 1;
}
// This callback gets called when a player disconnects from the server
public OnPlayerDisconnect(playerid, reason)
{
// Setup local variables
new BusSlot;
// Loop through all businesses the player owns
for (BusSlot = 0; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
{
// Check if the player has a business in this busslot
if (APlayerData[playerid][Business][BusSlot] != 0)
{
// Save the Busfile
BusinessFile_Save(APlayerData[playerid][Business][BusSlot]);
// Clear the BusID stored in this busslot
APlayerData[playerid][Business][BusSlot] = 0;
}
}
// Clear all data for this player
APlayerData[playerid][CurrentBusiness] = 0;
return 1;
}
// This callback gets called when a player interacts with a dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
// Select the proper dialog to process
switch (dialogid)
{
case DialogCreateBusSelType: Dialog_CreateBusSelType(playerid, response, listitem);
case DialogBusinessMenu: Dialog_BusinessMenu(playerid, response, listitem);
case DialogGoBusiness: Dialog_GoBusiness(playerid, response, listitem);
case DialogBusinessNameChange: Dialog_ChangeBusinessName(playerid, response, inputtext); // Change the name of your business
case DialogSellBusiness: Dialog_SellBusiness(playerid, response); // Sell the business
}
return 0;
}
// This callback gets called when a player spawns somewhere
public OnPlayerSpawn(playerid)
{
// Reset the BusID where the player is located
APlayerData[playerid][CurrentBusiness] = 0;
return 1;
}
// This callback gets called whenever a player dies
public OnPlayerDeath(playerid, killerid, reason)
{
// Reset the BusID where the player is located
APlayerData[playerid][CurrentBusiness] = 0;
return 1;
}
// This callback gets called when the player is selecting a class (but hasn't clicked "Spawn" yet)
public OnPlayerRequestClass(playerid, classid)
{
// Reset the BusID where the player is located
APlayerData[playerid][CurrentBusiness] = 0;
return 1;
}
// This callback is called when the player attempts to spawn via class-selection
public OnPlayerRequestSpawn(playerid)
{
// Reset the BusID where the player is located
APlayerData[playerid][CurrentBusiness] = 0;
return 1;
}
// ******************************************************************************************************************************
// Commands
// ******************************************************************************************************************************
// Lets the player add new businesses
COMMAND:createbusiness(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
// returning "SERVER: Unknown command" to the player
if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
// Setup local variables
new BusinessList[2000];
// Check if the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Construct the list of businesses
for (new BusType = 1; BusType < sizeof(ABusinessInteriors); BusType++)
{
format(BusinessList, sizeof(BusinessList), "%s%s\n", BusinessList, ABusinessInteriors[BusType][InteriorName]);
}
// Let the player choose a business-type via a dialog
ShowPlayerDialog(playerid, DialogCreateBusSelType, DIALOG_STYLE_LIST, "Choose business-type:", BusinessList, "Select", "Cancel");
}
else
SendClientMessage(playerid, 0xFF0000FF, "You must be on foot to create a business");
// Let the server know that this was a valid command
return 1;
}
// This command lets the player delete a business
COMMAND:delbusiness(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
// returning "SERVER: Unknown command" to the player
if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
// Setup local variables
new file[100], Msg[128];
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Loop through all player-owned businesses
for (new BusID = 1; BusID < MAX_BUSINESS; BusID++)
{
// Check if the business exists
if (IsValidDynamicPickup(ABusinessData[BusID][PickupID]))
{
// Check if the business has no owner
if (ABusinessData[BusID][Owned] == false)
{
// Check if the player is in range of the business-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]))
{
// Clear all data of the business
ABusinessData[BusID][BusinessName] = 0;
ABusinessData[BusID][BusinessX] = 0.0;
ABusinessData[BusID][BusinessY] = 0.0;
ABusinessData[BusID][BusinessZ] = 0.0;
ABusinessData[BusID][BusinessType] = 0;
ABusinessData[BusID][BusinessLevel] = 0;
ABusinessData[BusID][LastTransaction] = 0;
ABusinessData[BusID][Owned] = false;
ABusinessData[BusID][Owner] = 0;
// Destroy the mapicon, 3DText and pickup for the house
DestroyDynamicPickup(ABusinessData[BusID][PickupID]);
DestroyDynamicMapIcon(ABusinessData[BusID][MapIconID]);
DestroyDynamic3DTextLabel(ABusinessData[BusID][DoorText]);
ABusinessData[BusID][PickupID] = 0;
ABusinessData[BusID][MapIconID] = 0;
// Delete the business-file
format(file, sizeof(file), BusinessFile, BusID); // Construct the complete filename for this business-file
if (fexist(file)) // Make sure the file exists
fremove(file); // Delete the file
// Also let the player know he deleted the business
format(Msg, 128, "{00FF00}You have deleted the business with ID: {FFFF00}%i", BusID);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
// Exit the function
return 1;
}
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot delete an owned business");
}
}
// There was no house in range, so let the player know about it
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}No business in range to delete");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to delete a business");
// Let the server know that this was a valid command
return 1;
}
// This command lets the player buy a business when he's standing in range of a business that isn't owned yet
COMMAND:buybus(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Setup local variables
new Msg[128], BusType;
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Check if the player is near a business-pickup
for (new BusID = 1; BusID < sizeof(ABusinessData); BusID++)
{
// Check if this business is created (it would have a valid pickup in front of the door)
if (IsValidDynamicPickup(ABusinessData[BusID][PickupID]))
{
// Check if the player is in range of the business-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]))
{
// Check if the business isn't owned yet
if (ABusinessData[BusID][Owned] == false)
{
// Get the type of business
BusType = ABusinessData[BusID][BusinessType];
// Check if the player can afford this type of business business
if (INT_GetPlayerMoney(playerid) >= ABusinessInteriors[BusType][BusPrice])
Business_SetOwner(playerid, BusID); // Give ownership of the business to the player
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford this business"); // The player cannot afford this business
}
else
{
// Let the player know that this business is already owned by a player
format(Msg, 128, "{FF0000}This business is already owned by {FFFF00}%s", ABusinessData[BusID][Owner]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
// The player was in range of a business-pickup, so stop searching for the other business pickups
return 1;
}
}
}
// All businesses have been processed, but the player wasn't in range of any business-pickup, let him know about it
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}To buy a business, you have to be near a business-pickup");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't buy a business when you're inside a vehicle");
// Let the server know that this was a valid command
return 1;
}
// This command lets the player enter the house/business if he's the owner
COMMAND:enter(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Setup local variables
new BusID, BusType;
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Loop through all player-owned businesses
for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
{
// Get the business-id at the selected slot from the player
BusID = APlayerData[playerid][Business][BusSlot];
// Check if the player has a business in this slot
if (BusID != 0)
{
// Check if the player is in range of the business-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]))
{
// Get the business-type
BusType = ABusinessData[BusID][BusinessType];
// Set the worldid so other players cannot see him anymore
SetPlayerVirtualWorld(playerid, 2000 + BusID);
// Set the player inside the interior of the business
SetPlayerInterior(playerid, ABusinessInteriors[BusType][InteriorID]);
// Set the position of the player at the spawn-location of the business's interior
SetPlayerPos(playerid, ABusinessInteriors[BusType][IntX], ABusinessInteriors[BusType][IntY], ABusinessInteriors[BusType][IntZ]);
// Also set a tracking-variable to enable /busmenu to track in which business the player is
APlayerData[playerid][CurrentBusiness] = BusID;
// Also let the player know he can use /busmenu to control his business
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/busmenu{00FF00} to change options for your business");
// Exit the function
return 1;
}
}
}
}
// If no business was in range, allow other scripts to use the same command (like the housing-script)
return 0;
}
// This command opens a menu when you're inside your business to allow to access the options of your business
COMMAND:busmenu(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Setup local variables
new OptionsList[200], DialogTitle[200];
// Check if the player is inside a business
if (APlayerData[playerid][CurrentBusiness] != 0)
{
// Create the dialog title
format(DialogTitle, sizeof(DialogTitle), "Select option for %s", ABusinessData[APlayerData[playerid][CurrentBusiness]][BusinessName]);
// Create the options in the dialog
format(OptionsList, sizeof(OptionsList), "%sChange business-name\n", OptionsList);
format(OptionsList, sizeof(OptionsList), "%sUpgrade business\n", OptionsList);
format(OptionsList, sizeof(OptionsList), "%sRetrieve business earnings\n", OptionsList);
format(OptionsList, sizeof(OptionsList), "%sSell business\n", OptionsList);
format(OptionsList, sizeof(OptionsList), "%sExit business\n", OptionsList);
// Show the businessmenu
ShowPlayerDialog(playerid, DialogBusinessMenu, DIALOG_STYLE_LIST, DialogTitle, OptionsList, "Select", "Cancel");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You're not inside a business");
// Let the server know that this was a valid command
return 1;
}
// This command teleports you to your selected business
COMMAND:gobus(playerid, params[])
{
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Setup local variables
new BusinessList[1000], BusID, BusType, Earnings;
// Check if the player is not jailed
if (INT_IsPlayerJailed(playerid) == 0)
{
// Check if the player has a wanted level of less than 3
if (GetPlayerWantedLevel(playerid) < 3)
{
// Check if the player is not inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Ask to which business the player wants to port
for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
{
// Get the business-id
BusID = APlayerData[playerid][Business][BusSlot];
// Check if this businessindex is occupied
if (BusID != 0)
{
// Get the business-type
BusType = ABusinessData[BusID][BusinessType];
Earnings = (BusinessTransactionTime - ABusinessData[BusID][LastTransaction]) * ABusinessInteriors[BusType][BusEarnings] * ABusinessData[BusID][BusinessLevel];
format(BusinessList, 1000, "%s{00FF00}%s{FFFFFF} (earnings: $%i)\n", BusinessList, ABusinessData[BusID][BusinessName], Earnings);
}
else
format(BusinessList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", BusinessList, "Empty business-slot");
}
ShowPlayerDialog(playerid, DialogGoBusiness, DIALOG_STYLE_LIST, "Choose the business to go to:", BusinessList, "Select", "Cancel");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to be on-foot to port to your business");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use /gobus when you're wanted");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use /gobus when you're in jail");
// Let the server know that this was a valid command
return 1;
}
// ******************************************************************************************************************************
// Dialog-responses
// ******************************************************************************************************************************
// This dialog processes the chosen business-type and creates the business
Dialog_CreateBusSelType(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Setup some local variables
new BusType, BusID, Float:x, Float:y, Float:z, Msg[128], bool:EmptySlotFound = false;
// Get the player's position
GetPlayerPos(playerid, x, y, z);
// Get the business-type from the option the player chose
BusType = listitem + 1;
// Find a free business-id
for (BusID = 1; BusID < MAX_BUSINESS; BusID++)
{
// Check if this business ID is free
if (ABusinessData[BusID][BusinessType] == 0)
{
EmptySlotFound = true;
break; // Stop processing
}
}
// Check if an empty slot has been found
if (EmptySlotFound == false)
{
// If no empty slot was found, let the player know about it and exit the function
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Maximum number of businesses reached");
return 1;
}
// Set some default data at the index of NextFreeBusinessID (NextFreeBusinessID will point to the next free business-index)
ABusinessData[BusID][BusinessX] = x;
ABusinessData[BusID][BusinessY] = y;
ABusinessData[BusID][BusinessZ] = z;
ABusinessData[BusID][BusinessType] = BusType;
ABusinessData[BusID][BusinessLevel] = 1;
ABusinessData[BusID][Owned] = false;
// Add the pickup and 3DText at the location of the business-entrance (where the player is standing when he creates the business)
Business_CreateEntrance(BusID);
// Save the business
BusinessFile_Save(BusID);
// Inform the player that he created a new house
format(Msg, 128, "{00FF00}You've succesfully created business {FFFF00}%i{00FF00}", BusID);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
return 1;
}
// This function processes the businessmenu dialog
Dialog_BusinessMenu(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Setup local variables
new BusID, BusType, Msg[128], DialogTitle[200], UpgradePrice;
// Get the HouseID of the house where the player is
BusID = APlayerData[playerid][CurrentBusiness];
BusType = ABusinessData[BusID][BusinessType];
// Select an option based on the selection in the list
switch(listitem)
{
case 0: // Change business name
{
format(DialogTitle, 200, "Old business-name: %s", ABusinessData[BusID][BusinessName]);
ShowPlayerDialog(playerid, DialogBusinessNameChange, DIALOG_STYLE_INPUT, DialogTitle, "Enter a new name for your business", "OK", "Cancel");
}
case 1: // Upgrade the business
{
// Check if it's possible to upgrade further
if (ABusinessData[BusID][BusinessLevel] < 5)
{
// Get the upgrade-price
UpgradePrice = ABusinessInteriors[BusType][BusPrice];
// Check if the player can afford the upgrade
if (INT_GetPlayerMoney(playerid) >= UpgradePrice)
{
// Give the current earnings of the business to the player and update the LastTransaction time
Business_PayEarnings(playerid, BusID);
// Upgrade the business 1 level
ABusinessData[BusID][BusinessLevel]++;
// Let the player pay for the upgrade
INT_GivePlayerMoney(playerid, -UpgradePrice);
// Update the 3DText near the business's entrance to show what level the business is
Business_UpdateEntrance(BusID);
// Let the player know about it
format(Msg, 128, "{00FF00}You have upgraded your business to level {FFFF00}%i", ABusinessData[BusID][BusinessLevel]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford the upgrade");
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Your business has reached the maximum level, you cannot upgrade it further");
}
case 2: // Retrieve business earnings
{
// Give the current earnings of the business to the player and update the LastTransaction time
Business_PayEarnings(playerid, BusID);
}
case 3: // Sell business
{
format(Msg, 128, "Are you sure you want to sell your business for $%i?", (ABusinessInteriors[BusType][BusPrice] * ABusinessData[BusID][BusinessLevel]) / 2);
ShowPlayerDialog(playerid, DialogSellBusiness, DIALOG_STYLE_MSGBOX, "Are you sure?", Msg, "Yes", "No");
}
case 4: // Exit the business
{
Business_Exit(playerid, BusID);
}
}
return 1;
}
// Let the player change the name of his business
Dialog_ChangeBusinessName(playerid, response, inputtext[])
{
// Just close the dialog if the player clicked "Cancel" or if the player didn't input any text
if ((!response) || (strlen(inputtext) == 0)) return 1;
// Change the name of the business
format(ABusinessData[APlayerData[playerid][CurrentBusiness]][BusinessName], 100, inputtext);
// Also update the 3DText at the entrance of the business
Business_UpdateEntrance(APlayerData[playerid][CurrentBusiness]);
// Let the player know that the name of his business has been changed
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've changed the name of your business");
// Save the business-file
BusinessFile_Save(APlayerData[playerid][CurrentBusiness]);
return 1;
}
// Sell the business
Dialog_SellBusiness(playerid, response)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Get the BusinessID where the player is right now and the business-type
new BusID = APlayerData[playerid][CurrentBusiness];
new BusType = ABusinessData[BusID][BusinessType];
// Set the player in the normal world again
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
// Set the position of the player at the entrance of his business
SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
// Also clear the tracking-variable to track in which business the player is
APlayerData[playerid][CurrentBusiness] = 0;
// Clear the owner of the business
ABusinessData[BusID][Owned] = false;
ABusinessData[BusID][Owner] = 0;
// Clear the business-name and business-level
ABusinessData[BusID][BusinessName] = 0;
ABusinessData[BusID][BusinessLevel] = 1;
// Refund the player 50% of the worth of the business
INT_GivePlayerMoney(playerid, (ABusinessInteriors[BusType][BusPrice] * ABusinessData[BusID][BusinessLevel]) / 2);
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've sold your business");
// Clear the business-id from the player
for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
{
// If the business-slot if found where the business was added to the player
if (APlayerData[playerid][Business][BusSlot] == BusID)
{
// Clear the business-id
APlayerData[playerid][Business][BusSlot] = 0;
// Stop searching
break;
}
}
// Update the 3DText near the business's entrance to show other players that it's for sale again
Business_UpdateEntrance(BusID);
// Also save the sold business, otherwise the old ownership-data is still there
BusinessFile_Save(BusID);
return 1;
}
// This function processes the /gobus dialog
Dialog_GoBusiness(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Setup local variables
new BusIndex, BusID;
// The listitem directly indicates the business-index
BusIndex = listitem;
BusID = APlayerData[playerid][Business][BusIndex];
// Check if this is a valid business (BusID != 0)
if (BusID != 0)
{
// Get the coordinates of the business's entrance
SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have a business in this business-slot");
return 1;
}
// ******************************************************************************************************************************
// File functions
// ******************************************************************************************************************************
// This function loads the file that holds the current business-time
BusinessTime_Load()
{
// Setup local variables
new File:BFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
// Try to load the businesstime file
if (fexist(BusinessTimeFile))
{
BFile = fopen(BusinessTimeFile, io_read); // Open the businesstime-file for reading
fread(BFile, LineFromFile); // Read the first line of the file
// Keep reading until the end of the file is found (no more data)
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
// Store the proper value in the proper place
if (strcmp(ParameterName, "BusinessTime", false) == 0) // If the parametername is correct ("BusinessTime")
BusinessTransactionTime = strval(ParameterValue); // Store the BusinessTime
// Read the next line of the file
fread(BFile, LineFromFile);
}
// Close the file
fclose(BFile);
// Return if the file was read correctly
return 1;
}
else
return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
// This function saves the file that holds the current business-time
BusinessTime_Save()
{
// Setup local variables
new File:BFile, LineForFile[100];
BFile = fopen(BusinessTimeFile, io_write); // Open the businesstime-file for writing
format(LineForFile, 100, "BusinessTime %i\r\n", BusinessTransactionTime); // Construct the line: "BusinessTime <BusinessTransactionTime>"
fwrite(BFile, LineForFile); // And save it to the file
fclose(BFile); // Close the file
return 1;
}
// This function will load the business's datafile (used when the server is started to load all businesses)
BusinessFile_Load(BusID)
{
// Setup local variables
new file[100], File:BFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
// Construct the complete filename for this business-file
format(file, sizeof(file), BusinessFile, BusID);
// Check if the business-file exists
if (fexist(file))
{
// Open the businessfile for reading
BFile = fopen(file, io_read);
// Read the first line of the file
fread(BFile, LineFromFile);
// Keep reading until the end of the file is found (no more data)
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
// Check if there is anything in the LineFromFile (skipping empty lines)
if (strlen(LineFromFile) > 0)
{
// Store the proper value in the proper place
if (strcmp(ParameterName, "BusinessName", false) == 0) // If the parametername is correct ("BusinessName")
format(ABusinessData[BusID][BusinessName], 24, ParameterValue); // Store the BusinessName
if (strcmp(ParameterName, "BusinessX", false) == 0) // If the parametername is correct ("BusinessX")
ABusinessData[BusID][BusinessX] = floatstr(ParameterValue); // Store the BusinessX
if (strcmp(ParameterName, "BusinessY", false) == 0) // If the parametername is correct ("BusinessY")
ABusinessData[BusID][BusinessY] = floatstr(ParameterValue); // Store the BusinessY
if (strcmp(ParameterName, "BusinessZ", false) == 0) // If the parametername is correct ("BusinessZ")
ABusinessData[BusID][BusinessZ] = floatstr(ParameterValue); // Store the BusinessZ
if (strcmp(ParameterName, "BusinessType", false) == 0) // If the parametername is correct ("BusinessType")
ABusinessData[BusID][BusinessType] = strval(ParameterValue); // Store the BusinessType
if (strcmp(ParameterName, "BusinessLevel", false) == 0) // If the parametername is correct ("BusinessLevel")
ABusinessData[BusID][BusinessLevel] = strval(ParameterValue); // Store the BusinessLevel
if (strcmp(ParameterName, "LastTransaction", false) == 0) // If the parametername is correct ("LastTransaction")
ABusinessData[BusID][LastTransaction] = strval(ParameterValue); // Store the LastTransaction
if (strcmp(ParameterName, "Owned", false) == 0) // If the parametername is correct ("Owned")
{
if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
ABusinessData[BusID][Owned] = true; // House is owned
else
ABusinessData[BusID][Owned] = false; // House is not owned
}
if (strcmp(ParameterName, "Owner", false) == 0) // If the parametername is correct ("Owner")
format(ABusinessData[BusID][Owner], 24, ParameterValue);
}
// Read the next line of the file
fread(BFile, LineFromFile);
}
// Close the file
fclose(BFile);
// Create the business-entrance and set data
Business_CreateEntrance(BusID);
// Increase the amount of businesses loaded
TotalBusiness++;
// Return if the file was read correctly
return 1;
}
else
return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
// This function will save the given business
BusinessFile_Save(BusID)
{
// Setup local variables
new file[100], File:BFile, LineForFile[100];
// Construct the complete filename for this business
format(file, sizeof(file), BusinessFile, BusID);
// Open the business-file for writing
BFile = fopen(file, io_write);
format(LineForFile, 100, "BusinessName %s\r\n", ABusinessData[BusID][BusinessName]); // Construct the line: "BusinessName <BusinessName>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BusinessX %f\r\n", ABusinessData[BusID][BusinessX]); // Construct the line: "BusinessX <BusinessX>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BusinessY %f\r\n", ABusinessData[BusID][BusinessY]); // Construct the line: "BusinessY <BusinessY>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BusinessZ %f\r\n", ABusinessData[BusID][BusinessZ]); // Construct the line: "BusinessZ <BusinessZ>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BusinessType %i\r\n", ABusinessData[BusID][BusinessType]); // Construct the line: "BusinessType <BusinessType>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BusinessLevel %i\r\n", ABusinessData[BusID][BusinessLevel]); // Construct the line: "BusinessLevel <BusinessLevel>"
fwrite(BFile, LineForFile); // And save it to the file
format(LineForFile, 100, "LastTransaction %i\r\n", ABusinessData[BusID][LastTransaction]); // Construct the line: "LastTransaction <LastTransaction>"
fwrite(BFile, LineForFile); // And save it to the file
if (ABusinessData[BusID][Owned] == true) // Check if the business is owned
{
format(LineForFile, 100, "Owned Yes\r\n"); // Construct the line: "Owned Yes"
fwrite(BFile, LineForFile); // And save it to the file
}
else
{
format(LineForFile, 100, "Owned No\r\n"); // Construct the line: "Owned No"
fwrite(BFile, LineForFile); // And save it to the file
}
format(LineForFile, 100, "Owner %s\r\n", ABusinessData[BusID][Owner]); // Construct the line: "Owner <Owner>"
fwrite(BFile, LineForFile); // And save it to the file
fclose(BFile); // Close the file
return 1;
}
// ******************************************************************************************************************************
// Business functions
// ******************************************************************************************************************************
// This timer increases the variable "BusinessTransactionTime" every minute and saves the businesstime file
forward Business_TransactionTimer();
public Business_TransactionTimer()
{
// Increase the variable by one
BusinessTransactionTime++;
// And save it to the file
BusinessTime_Save();
}
// This function returns the first free business-slot for the given player
Player_GetFreeBusinessSlot(playerid)
{
// Check if the player has room for another business (he hasn't bought the maximum amount of businesses per player yet)
// and get the slot-id
for (new BusIndex; BusIndex < MAX_BUSINESSPERPLAYER; BusIndex++) // Loop through all business-slots of the player
if (APlayerData[playerid][Business][BusIndex] == 0) // Check if this business slot is free
return BusIndex; // Return the free BusIndex for this player
// If there were no free business-slots, return "-1"
return -1;
}
// This function sets ownership of the business to the given player
Business_SetOwner(playerid, BusID)
{
// Setup local variables
new BusSlotFree, Name[24], Msg[128], BusType;
// Get the first free business-slot from this player
BusSlotFree = Player_GetFreeBusinessSlot(playerid);
// Check if the player has a free business-slot
if (BusSlotFree != -1)
{
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Store the business-id for the player
APlayerData[playerid][Business][BusSlotFree] = BusID;
// Get the business-type
BusType = ABusinessData[BusID][BusinessType];
// Let the player pay for the business
INT_GivePlayerMoney(playerid, -ABusinessInteriors[BusType][BusPrice]);
// Set the business as owned
ABusinessData[BusID][Owned] = true;
// Store the owner-name for the business
format(ABusinessData[BusID][Owner], 24, Name);
// Set the level to 1
ABusinessData[BusID][BusinessLevel] = 1;
// Set the default business-name
format(ABusinessData[BusID][BusinessName], 100, ABusinessInteriors[BusType][InteriorName]);
// Store the current transaction-time (this is used so the player can only retrieve cash from the business from the moment he bought it)
ABusinessData[BusID][LastTransaction] = BusinessTransactionTime;
// Also, update 3DText of this business
Business_UpdateEntrance(BusID);
// Save the business-file
BusinessFile_Save(BusID);
// Let the player know he bought the business
format(Msg, 128, "{00FF00}You've bought the business for {FFFF00}$%i", ABusinessInteriors[BusType][BusPrice]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You already own the maximum amount of allowed businesses per player");
return 1;
}
// This function adds a pickup for the given business
Business_CreateEntrance(BusID)
{
// Setup local variables
new Msg[128], Float:x, Float:y, Float:z, BusType, Icon;
// Get the coordinates of the house's pickup (usually near the door)
x = ABusinessData[BusID][BusinessX];
y = ABusinessData[BusID][BusinessY];
z = ABusinessData[BusID][BusinessZ];
// Get the business-type and icon
BusType = ABusinessData[BusID][BusinessType];
Icon = ABusinessInteriors[BusType][IconID];
// Add a dollar-sign to indicate this business
ABusinessData[BusID][PickupID] = CreateDynamicPickup(1274, 1, x, y, z, 0);
// Add a map-icon depending on which type the business is
ABusinessData[BusID][MapIconID] = CreateDynamicMapIcon(x, y, z, Icon, 0, 0, 0, -1, 150.0);
// Add a new 3DText at the business's location (usually near the door)
if (ABusinessData[BusID][Owned] == true)
{
// Create the 3DText that appears above the business-pickup (displays the businessname, the name of the owner and the current level)
format(Msg, 128, "%s\nOwned by: %s\nBusiness-level: %i\n/enter", ABusinessData[BusID][BusinessName], ABusinessData[BusID][Owner], ABusinessData[BusID][BusinessLevel]);
ABusinessData[BusID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
}
else
{
// Create the 3DText that appears above the business-pickup (displays the price of the business and the earnings)
format(Msg, 128, "%s\nAvailable for\n$%i\nEarnings: $%i\n/buybus", ABusinessInteriors[BusType][InteriorName], ABusinessInteriors[BusType][BusPrice], ABusinessInteriors[BusType][BusEarnings]);
ABusinessData[BusID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
}
}
// This function changes the 3DText for the given business (used when buying or selling a business)
Business_UpdateEntrance(BusID)
{
// Setup local variables
new Msg[128], BusType;
// Get the business-type
BusType = ABusinessData[BusID][BusinessType];
// Update the 3DText at the business's location (usually near the door)
if (ABusinessData[BusID][Owned] == true)
{
// Create the 3DText that appears above the business-pickup (displays the businessname, the name of the owner and the current level)
format(Msg, 128, "%s\nOwned by: %s\nBusiness-level: %i\n/enter", ABusinessData[BusID][BusinessName], ABusinessData[BusID][Owner], ABusinessData[BusID][BusinessLevel]);
UpdateDynamic3DTextLabelText(ABusinessData[BusID][DoorText], 0x008080FF, Msg);
}
else
{
// Create the 3DText that appears above the business-pickup (displays the price of the business and the earnings)
format(Msg, 128, "%s\nAvailable for\n$%i\nEarnings: $%i\n/buybus", ABusinessInteriors[BusType][InteriorName], ABusinessInteriors[BusType][BusPrice], ABusinessInteriors[BusType][BusEarnings]);
UpdateDynamic3DTextLabelText(ABusinessData[BusID][DoorText], 0x008080FF, Msg);
}
}
// This function pays the current earnings of the given business to the player
Business_PayEarnings(playerid, BusID)
{
// Setup local variables
new Msg[128];
// Get the business-type
new BusType = ABusinessData[BusID][BusinessType];
// Calculate the earnings of the business since the last transaction
// This is calculated by the number of minutes between the current business-time and last business-time, multiplied by the earnings-per-minute and business-level
new Earnings = (BusinessTransactionTime - ABusinessData[BusID][LastTransaction]) * ABusinessInteriors[BusType][BusEarnings] * ABusinessData[BusID][BusinessLevel];
// Reset the last transaction time to the current time
ABusinessData[BusID][LastTransaction] = BusinessTransactionTime;
// Reward the player with his earnings
INT_GivePlayerMoney(playerid, Earnings);
// Inform the player that he has earned money from his business
format(Msg, 128, "{00FF00}Your business has earned {FFFF00}$%i{00FF00} since your last withdrawl", Earnings);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
// This function is used to spawn back at the entrance of your business
Business_Exit(playerid, BusID)
{
// Set the player in the normal world again
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
// Set the position of the player at the entrance of his business
SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
// Also clear the tracking-variable to track in which business the player is
APlayerData[playerid][CurrentBusiness] = 0;
// Check if there is a timer-value set for exiting the business (this timer freezes the player while the environment is being loaded)
if (ExitBusinessTimer > 0)
{
// Don't allow the player to fall
TogglePlayerControllable(playerid, 0);
// Let the player know he's frozen while the environment loads
GameTextForPlayer(playerid, "Waiting for the environment to load", ExitBusinessTimer, 4);
// Start a timer that will allow the player to fall again when the environment has loaded
SetTimerEx("Business_ExitTimer", ExitBusinessTimer, false, "ii", playerid, BusID);
}
return 1;
}
forward Business_ExitTimer(playerid, BusID);
public Business_ExitTimer(playerid, BusID)
{
// Allow the player to move again (environment should have been loaded now)
TogglePlayerControllable(playerid, 1);
return 1;
}
// ******************************************************************************************************************************
// Support functions
// ******************************************************************************************************************************
// This function is copied from the include-file "dutils.inc"
stock StripNewLine(string[])
{
new len = strlen(string); // Get the length of the given string
if (string[0] == 0) return ; // If the given string is empty, exit the function
if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) // If the string ends with \n or \r
{
string[len - 1] = 0; // Replace the \n or \r with a 0 character
if (string[0]==0) return ; // If the string became empty, exit the function
if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) // Check again if the string ends with \n or \r
string[len - 2] = 0; // Replace the \n or \r again with a 0 character
}
}
// ******************************************************************************************************************************
// Special functions that try to access external public functions to retreive or set data from another script
// ******************************************************************************************************************************
// This function is used to get the player's money
INT_GetPlayerMoney(playerid)
{
// Setup local variables
new Money;
// Try to call the external function to get the player's money (used to get the serversided money for this player)
Money = CallRemoteFunction("Admin_GetPlayerMoney", "i", playerid);
// The external function returned "0" (as the player doesn't have any money yet), or the function is not used in another script
if (Money == 0)
return GetPlayerMoney(playerid); // Return the normal money of the player
else
return Money; // Return the money that was returned by the external function
}
// This function is used to set the player's money
INT_GivePlayerMoney(playerid, Money)
{
// Setup local variables
new Success;
// Try to call the external function to get the player's money (used to get the serversided money for this player)
Success = CallRemoteFunction("Admin_GivePlayerMoney", "ii", playerid, Money);
// The external function returned "0" as the function is not used in another script
if (Success == 0)
GivePlayerMoney(playerid, Money); // Use the normal money (client-sided money)
}
// This function checks if the admin-level of a player is sufficient
INT_CheckPlayerAdminLevel(playerid, AdminLevel)
{
// Setup local variables
new Level;
// Check if the player is an RCON admin
if (IsPlayerAdmin(playerid))
return 1; // Return 1 to indicate this player has a sufficient admin-level to use a command
// If the player is not an RCON admin, try to get his admin-level from an external script using a remote function
Level = CallRemoteFunction("Admin_GetPlayerAdminLevel", "i", playerid);
// Check if the player has a sufficient admin-level
if (Level >= AdminLevel)
return 1; // Return 1 to indicate this player has a sufficient admin-level
else
return 0; // Return 0 to indicate this player has an insufficient admin-level
}
// This function checks if the player has logged in properly by entering his password
INT_IsPlayerLoggedIn(playerid)
{
// Setup local variables
new LoggedIn;
// Try to determine if the player logged in properly by entering his password in another script
LoggedIn = CallRemoteFunction("Admin_IsPlayerLoggedIn", "i", playerid);
// Check if the player has logged in properly
switch (LoggedIn)
{
case 0: return 1; // No admin script present that holds the LoggedIn status of a player, so allow a command to be used
case 1: return 1; // The player logged in properly by entering his password, allow commands to be used
case -1: return 0; // There is an admin script present, but the player hasn't entered his password yet, so block all commands
// This prevents executing the commands using F6 during login with an admin-account before entering a password
}
// In any other case, block all commands
return 0;
}
// This function tries to cetermine if the player is in jail
INT_IsPlayerJailed(playerid)
{
// Setup local variables
new Jailed;
// Try to determine if the player is jailed
Jailed = CallRemoteFunction("Admin_IsPlayerJailed", "i", playerid);
// Check if the player is jailed
switch (Jailed)
{
case 0: return 0; // No admin script present, so there is no jail either, player cannot be jailed in this case
case 1: return 1; // The player is jailed, so return "1"
case -1: return 0; // There is an admin script present, but the player isn't jailed
}
// In any other case, return "0" (player not jailed)
return 0;
}
// ******************************************************************************************************************************
// External functions to be used from within other filterscripts or gamemode (these aren't called anywhere inside this script)
// These functions can be called from other filterscripts or the gamemode to get data from the housing filterscript
// ******************************************************************************************************************************
// ******************************************************************************************************************************
// Functions that need to be placed in the gamemode or filterscript which holds the playerdata
// Only needed when the server uses server-sided money, otherwise the normal money is used
// ******************************************************************************************************************************
/*
// This function is used to get the player's money
forward Admin_GetPlayerMoney(playerid);
public Admin_GetPlayerMoney(playerid)
{
return APlayerData[playerid][PlayerMoney];
}
// This function is used to get the player's money
forward Admin_GivePlayerMoney(playerid, Money);
public Admin_GivePlayerMoney(playerid, Money)
{
// Add the given money to the player's account
APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + Money;
// Return that the function had success
return 1;
}
// This function is used to get the player's admin-level
forward Admin_GetPlayerAdminLevel(playerid);
public Admin_GetPlayerAdminLevel(playerid)
{
return APlayerData[playerid][AdminLevel];
}
// This function is used to determine if the player has logged in (he succesfully entered his password)
forward Admin_IsPlayerLoggedIn(playerid);
public Admin_IsPlayerLoggedIn(playerid)
{
if (APlayerData[playerid][LoggedIn] == true)
return 1; // The player has logged in succesfully
else
return -1; // The player hasn't logged in (yet)
}
// This function is used to determine if a player is jailed
forward Admin_IsPlayerJailed(playerid);
public Admin_IsPlayerJailed(playerid)
{
// Check if a player has jaimtime left
if (APlayerData[playerid][PlayerJailed] == true)
return 1; // The player is still jailed
else
return -1; // The player is not jailed
}
*/