Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- s-Admin V1.4 Release
- ->About:
- s-Admin is a simple admin script with just the nessesary commands, why ?
- Well i like admin scripts clean and usefull, and not full of useless commands.
- It supports MYSQL, but also Y_INI so the users can decide for themself if they want to use
- textfiles or an online database. s-Admin also provides a dialogged GUI, the administrator can just
- doubleclick on a player in the scorelist and it will show up a dialog with several options.
- s-Admin also saves the player stats (like score,money) and includes an anti-jail/mute evade.
- ->Commands:
- Player (Level 0):
- Command: Parameters: Explaination:
- /admins none Lists all online administrator
- /changepassword [oldpassword] [newpassword] Allows the player to change his password
- /stats none Rettreive's playerstats
- /whois [playerid] Rettreive information about given playerid
- /whowas [playername] Rettreive information about given playername
- /report [playerid] [reason] Reports another player (this will be shown to online admins and in Rcon console)
- Moderator (Level 1):
- Command: Parameters: Explaination:
- /acmds none Shows all admin commands
- /a [text] Adminchat
- /announce [text] Announce a message
- /spectate [playerid] Spectate player
- /stop none Stops spectating player
- /disarm [playerid] Resets player weapons of playerid
- /mute [playerid] [reason (optional)] Mutes player
- /unmute [playerid] Unmutes player
- /freeze [playerid] [reason (optional)] Freezes player
- /unfreeze [playerid] Unfreezes player
- /jail [playerid] [reason (optional)] Jails player
- /unjail [playerid] Unjails player
- /kick [playerid] [reason (optional)] Kicks player
- Administrator (Level 2):
- Command: Parameters: Explaination:
- /veh [vehiclename] Spawns a vehicle for the admin
- /get [playerid] Teleports given playerid to the admin
- /goto [playerid] Teleports admin to the given playerid
- /giveweapon [playerid][weaponid][ammo] Gives weapon to given playerid
- /setmoney [playerid][ammount] Changes money of playerid
- /setscore [playerid][ammount] Changes score of playerid
- /explode [playerid] Explodes playerid
- /ban [playerid] [reason (optional)] Bans the playerid
- /banip [ip] Bans the given IP
- /annoy [playerid] Releases a cow on the player! (Known from Hiddos's annoying cow script)
- /catchcow Removes released cow
- Owner (Level 3):
- Command: Parameters: Explaination:
- /setlevel [playerid][level] Adjust the rights of the player (Level 0/3)
- /unbanip [ip] Unbans the given IP
- ->Credits:
- Hiddos for his annoying cow script
- Zeex for ZCMD
- Y_Less for sscanf2
- Y_Less for Y_INI
- G-sTyLeZzZ for his MYSQL Plugin
- ->Changelog:
- 1b:
- - /stats colors are better
- - /admins colors are better
- - adminchat has now a space
- 1c:
- - You cannot click on yourself in the scorelist anymore
- - /countdown command added
- - /veh has been optimised
- - /giveweapon is now using weapon names instead of ID's
- - s-Admin is now using gLibrary 1.1
- 1.1:
- - Optimised code (using gLibrary 1.2) and better colors
- - s-Admin now also saves IP
- - passwords will now be hashed with WhirlPool
- - /whois is now public
- - /whowas added
- 1.2:
- - Returns fixed
- - Colors changed again (looks much better now)
- - Some VERY important security issues fixed (logging in)
- - Return problem fixed (compability with other scripts using dialogs)
- 1.3:
- - System uses new gLibrary (problem solved with OnPlayerDisconnect)
- - /veh has been fixed
- - /report has been fixed
- */
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #include <gLibrary>
- native WP_Hash(buffer[], len, const str[]);
- //================================================================================================================
- //------------------Settings------------------
- #define USE_MYSQL_DATABASE false //if defined false, it will use Y_INI (text files) instead
- #define MAX_LOGIN_ATTEMPTS 3 //maximum login attempts before kick
- #define DIALOG_RANGE 100 //dialog range (100 by default, will use dialogid's 100-104)
- #define ALLOW_ANNOY true //allow administrators so release a crazy cow on players!
- #define ALLOW_ADMINS true //you can turn this off if you dont want to allow players using /admins to see if there is an admin online
- #define ALLOW_VEH true //allows admins to spawn vehicles
- //----------------SQL Settings---------------- //only needs to be set when you use mysql db
- #define HOST "localhost"
- #define USER "root"
- #define DB "s-admin"
- #define PASS ""
- //================================================================================================================
- //ignore these
- #define abs(%0) ((%0) >= 0 ? (%0) : -(%0))
- new cow_victim = -1, object_cow, movecow_timer;
- #if USE_MYSQL_DATABASE == true
- #include <yoursql>
- #else
- #define MAX_INI_ENTRY_TEXT 129
- #include <YSI/y_ini>
- #endif
- #define color_red gCOLOR_RED
- #define color_green gCOLOR_GREEN
- #define color_gray gCOLOR_GRAY
- #define color_orange gCOLOR_ORANGE
- #define color_blue 0xADD8E6FF
- #define color_yellow gCOLOR_YELLOW
- #define DIALOG_REGISTER DIALOG_RANGE
- #define DIALOG_LOGIN DIALOG_RANGE +1
- #define DIALOG_CHANGENICK DIALOG_RANGE +2
- #define DIALOG_REPORT DIALOG_RANGE +3
- #define DIALOG_ADMIN DIALOG_RANGE +4
- enum gPlayerInfo
- {
- Username[32],
- Password[129],
- Muted,
- Jailed,
- Score,
- Money,
- Level,
- Ip[32]
- }
- new PlayerInfo[MAX_PLAYERS][gPlayerInfo];
- enum gTempInfo
- {
- Username[32],
- Password[129],
- Muted,
- Jailed,
- Score,
- Money,
- Level,
- Ip[32]
- }
- new TempInfo[gPlayerInfo];
- new UpdateSpectateTimer[MAX_PLAYERS];
- new bool:CountDownInProgress = false;
- new countdown_counter = 5;
- //================================================================================================================
- //basic script
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Gamer's admin script V1.1 ");
- print("--------------------------------------\n");
- #if USE_MYSQL_DATABASE == true
- yoursql_connect(HOST,USER,DB,PASS);
- #endif
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- OnPlayerConnect(i);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- SaveUser(i);
- }
- #if USE_MYSQL_DATABASE == true
- yoursql_close();
- #endif
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- format(PlayerInfo[playerid][Username],32," ");
- format(PlayerInfo[playerid][Password],32," ");
- PlayerInfo[playerid][Level] = 0;
- new pName[MAX_PLAYER_NAME],string[96];GetPlayerName(playerid,pName,sizeof pName);
- if(IsPlayerNPC(playerid)) return 1;
- #if USE_MYSQL_DATABASE == true
- format(string,sizeof string,"SELECT * FROM users WHERE Username = '%s'",yoursql_escape_string(pName));
- if(yoursql_countrows(string) == 0)
- {
- ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registo de Conta","Regista a tua conta escrevendo a tua password","Registar","Sair");
- } else {
- LoadUser(playerid,pName);
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Registo de Conta","Esta conta esta registada, escreve a tua password.","Login","Mudar Nome");
- SetPVarInt(playerid,"attempt",0);
- }
- #else
- format(string,sizeof string,"Users/%s.ini",pName);
- if(!fexist(string))
- {
- ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registo de Conta","Regista a tua conta escrevendo a tua password","Registar","Sair");
- } else {
- LoadUser(playerid,pName);
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Account registration","Esta conta esta registada, escreve a tua password.","Login","Mudar Nome");
- SetPVarInt(playerid,"attempt",0);
- }
- #endif
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(PlayerInfo[playerid][Jailed] == 1)
- {
- SendClientMessageToAllEx(color_red,"ss",PlayerInfo[playerid][Username]," is automaticly jailed (Jail evade).");
- SetTimerEx("JailOnSpawnDelay",1000,false,"i",playerid);
- } else if (PlayerInfo[playerid][Muted] == 1){
- SendClientMessageToAllEx(color_red,"ss",PlayerInfo[playerid][Username]," is automaticly muted (Mute evade).");
- }
- return 1;
- }
- forward JailOnSpawnDelay(playerid);
- public JailOnSpawnDelay(playerid)
- {
- JailPlayer(playerid);
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(!IsPlayerNPC(playerid))
- {
- SaveUser(playerid);
- if(cow_victim == playerid)
- {
- StopAnnoying();
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- if(playerid == clickedplayerid) return SendClientMessage(playerid,color_red,"You cannot open the usermenu for yourself!");
- SetPVarInt(playerid,"selectedid",clickedplayerid);
- switch(PlayerInfo[playerid][Level])
- {
- case 0:{
- if(!IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid,DIALOG_REPORT,DIALOG_STYLE_INPUT,"Report player","Please fill in a valid reason:","OK","Cancel");
- } else ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Administrator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\nJail\nUnjail\nKick\nGet\nGoto\nAnnoy\nBan","OK","Cancel");
- }
- case 1:ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Moderator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\nJail\nUnjail\nKick","OK","Cancel");
- case 2,3:ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Administrator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\n\nJail\nUnjail\nKick\nGet\nGoto\nAnnoy\nBan","OK","Cancel");
- }
- return 1;
- }
- //================================================================================================================
- //dialog handler
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case(DIALOG_REGISTER):
- {
- if(!response)
- {
- SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Quit at registration).");
- Kick(playerid);
- }
- OnPlayerRegister(playerid,inputtext);
- }
- case(DIALOG_LOGIN):
- {
- if(!response) return ShowPlayerDialog(playerid,DIALOG_CHANGENICK,DIALOG_STYLE_INPUT,"Account registration","Please fill in a nickname:","OK","Quit");
- if(GetPVarInt(playerid,"attempt") == MAX_LOGIN_ATTEMPTS)
- {
- SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Failed to login).");
- Kick(playerid);
- } else {
- if(!strlen(inputtext))
- {
- SendClientMessageEx(playerid,color_red,"sisis","You have failed to login (attempt ",GetPVarInt(playerid,"attempt") +1,"/",MAX_LOGIN_ATTEMPTS,").");
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Account registration","This account is registered! Please fill in a password to join.","Login","Change username");
- SetPVarInt(playerid,"attempt",GetPVarInt(playerid,"attempt") +1);
- printf("%s failed to login (attempt %i/%i).",PlayerInfo[playerid][Username],GetPVarInt(playerid,"attempt"),MAX_LOGIN_ATTEMPTS);
- }
- new buffer[129];WP_Hash(buffer,sizeof buffer,inputtext);
- if(!strcmp(buffer,PlayerInfo[playerid][Password]))
- {
- if(PlayerInfo[playerid][Level] > 0)
- {
- SendClientMessageEx(playerid,color_green,"sis","You have succesfully logged in as level ",PlayerInfo[playerid][Level]," admin!");
- } else SendClientMessage(playerid,color_green,"You have succesfully logged in.");
- SendClientMessageToAllEx(color_green,"ss",PlayerInfo[playerid][Username]," has logged in, welcome back!");
- printf("%s has logged in.",PlayerInfo[playerid][Username]);
- } else {
- SendClientMessageEx(playerid,color_red,"sisis","You have failed to login (attempt ",GetPVarInt(playerid,"attempt") +1,"/",MAX_LOGIN_ATTEMPTS,").");
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Account registration","This account is registered! Please fill in a password to join.","Login","Change username");
- SetPVarInt(playerid,"attempt",GetPVarInt(playerid,"attempt") +1);
- printf("%s failed to login (attempt %i/%i).",PlayerInfo[playerid][Username],GetPVarInt(playerid,"attempt"),MAX_LOGIN_ATTEMPTS);
- }
- }
- }
- case(DIALOG_CHANGENICK):
- {
- if(!response)
- {
- SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Quit at registration).");
- Kick(playerid);
- }
- if(!strlen(inputtext))
- {
- SendClientMessage(playerid,color_red,"Account registration: Please fill in a valid username!");
- ShowPlayerDialog(playerid,DIALOG_CHANGENICK,DIALOG_STYLE_INPUT,"Account registration","Please fill in a nickname:","OK","Quit");
- }
- SetPlayerName(playerid,inputtext);
- OnPlayerConnect(playerid);
- }
- case(DIALOG_REPORT):
- {
- if(!response) return 1;
- new id = GetPVarInt(playerid,"selectedid");
- new reason[64];format(reason,sizeof reason,"%s",inputtext);
- if(!strlen(reason)) return SendClientMessage(playerid,color_red,"No valid reason.");
- new counter = 0;for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerInfo[i][Level] > 0)
- {
- SendClientMessageEx(i,color_orange,"sssisssisss","Incomming report from ",PlayerInfo[playerid][Username],"(",playerid,") Reporting ",PlayerInfo[id][Username],"(",id,"), Reason: ",reason,".");
- counter++;
- }
- }
- printf("%s has reported %s (Reason:%s)",PlayerInfo[playerid][Username],PlayerInfo[id][Username],reason);
- return SendClientMessageEx(playerid,color_orange,"sis","O teu report foi enviado a todos os administradores (",counter," de momento.).");
- }
- case(DIALOG_ADMIN):
- {
- if(!response) return 1;
- new id = GetPVarInt(playerid,"selectedid");
- switch(listitem)
- {
- case 0://spectate
- {
- if(GetPVarInt(playerid,"spectating") == 1) return SendClientMessage(playerid,color_red,"You are already spectating! Please use /stop to turn spectatemode off.");
- TogglePlayerSpectating(playerid,1);
- SetPVarInt(playerid,"spectating",1);
- if(IsPlayerInAnyVehicle(id))
- {
- SetPVarInt(playerid,"state",1);
- PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
- } else {
- SetPVarInt(playerid,"state",0);
- PlayerSpectatePlayer(playerid,id);
- }
- UpdateSpectateTimer[playerid] = SetTimerEx("UpdateAdminSpectate",1000,true,"ii",playerid,id);
- return SendClientMessageEx(playerid,color_green,"sss","You are now spectating ",PlayerInfo[id][Username]," . You can use /stop to switch back to normal mode.");
- }
- case 1: //disarm
- {
- ResetPlayerWeapons(id);
- return SendClientMessageToAllEx(color_red,"ssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} disarmed ",PlayerInfo[id][Username],".");
- }
- case 2://mute
- {
- if(PlayerInfo[id][Muted] == 1) return SendClientMessage(playerid,color_red,"Player is already muted!");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Muted] = 1;
- return MutePlayer(id);
- }
- case 3://unmute
- {
- if(PlayerInfo[id][Muted] == 0) return SendClientMessage(playerid,color_red,"Player is not muted!");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unmuted ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Muted] = 0;
- return UnMutePlayer(id);
- }
- case 4://freeze
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username],".");
- return TogglePlayerControllable(id,0);
- }
- case 5://unfreeze
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unfroze ",PlayerInfo[id][Username],".");
- return TogglePlayerControllable(id,1);
- }
- case 6://jail
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Jailed] = 1;
- return JailPlayer(id);
- }
- case 7: //unjail
- {
- if(PlayerInfo[id][Jailed] == 0) return SendClientMessage(playerid,color_red,"Player is not jailed!");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unjailed ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Jailed] = 0;
- return UnJailPlayer(id);
- }
- case 8://kick
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username],".");
- return Kick(id);
- }
- case 9://get
- {
- new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);x = x +2;
- SetPlayerPos(id,x,y,z);
- SendClientMessageEx(playerid,color_green,"sss","You have teleported ",PlayerInfo[id][Username]," to your position!");
- return SendClientMessageEx(id,color_green,"sss","Administrador ",PlayerInfo[playerid][Username]," has teleported you to his position!");
- }
- case 10://goto
- {
- new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z);x = x +2;
- SetPlayerPos(playerid,x,y,z);
- return SendClientMessageEx(playerid,color_red,"sss","You have teleported to ",PlayerInfo[id][Username],"'s position!");
- }
- case 11://annoy
- {
- if(cow_victim != -1) return SendClientMessage(playerid,color_red,"Sorry! It seems like your cow has already been stolen by another Administrador.");
- #if ALLOW_ANNOY == false
- return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled.");
- #else
- AnnoyPlayer(id);
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} has released his cow on ",PlayerInfo[id][Username]," !!!");
- return SendClientMessageEx(playerid,color_green,"sss","You have released your cow on ",PlayerInfo[id][Username],"! please use /catchcow to bring him back.");
- #endif
- }
- case 12://ban
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username],".");
- return Ban(id);
- }
- }
- }
- }
- return 0;
- }
- //================================================================================================================
- //Player commands:
- COMMAND:in(playerid,params[])
- {
- return SendClientMessageEx(playerid,gCOLOR_RED,"sf","Speed: ",GetVehicleSpeed(GetPlayerVehicleID(playerid),0));
- }
- COMMAND:test(playerid,params[])
- {
- return PutPlayerInVehicle(playerid,GetClosestVehicleForPlayer(playerid),0);
- }
- COMMAND:reconnect(playerid,params[])
- {
- SendClientMessage(playerid,gCOLOR_RED,"You will now be reconnected to the server, DO NOT LEAVE!");
- SetPlayerToReconnect(playerid);
- return 1;
- }
- COMMAND:changepassword(playerid,params[])
- {
- new oldpass[129],newpass[129];
- if(sscanf(params,"s[32]s[32]",oldpass,newpass)) return SendClientMessage(playerid,color_red,"USAGE: /changepassword [oldpassword] [newpassword]");
- WP_Hash(oldpass,sizeof oldpass,oldpass);
- if(strcmp(PlayerInfo[playerid][Password],oldpass)) return SendClientMessage(playerid,color_red,"ERROR! Your current password does not match with your entered password!");
- #if USE_MYSQL_DATABASE == true
- WP_Hash(PlayerInfo[playerid][Password],129,newpass);
- #else
- WP_Hash(PlayerInfo[playerid][Password],129,newpass);
- #endif
- SaveUser(playerid);
- return SendClientMessage(playerid,color_green,"Your password has succesfully been changed.");
- }
- COMMAND:stats(playerid,params[])
- {
- SendClientMessage(playerid,color_green,"Your current stats:");
- SendClientMessageEx(playerid,color_yellow,"sis","Score: ",GetPlayerScore(playerid),".");
- SendClientMessageEx(playerid,color_yellow,"sis","Money: ",GetPlayerMoney(playerid),".");
- return 1;
- }
- COMMAND:whois(playerid,params[])
- {
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /whois [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- SendClientMessageEx(playerid,color_orange,"sis","Who is ID ",id,".");
- SendClientMessageEx(playerid,color_yellow,"sss","Username: {FFFFFF}",PlayerInfo[id][Username],".");
- switch(PlayerInfo[id][Level])
- {
- case 0:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Jogador.");
- case 1:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Moderador.");
- case 2:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Administrador.");
- case 3:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Owner.");
- }
- SendClientMessageEx(playerid,color_yellow,"sis","Score: ",GetPlayerScore(id),".");
- SendClientMessageEx(playerid,color_yellow,"sis","Money: ",GetPlayerMoney(id),".");
- SendClientMessageEx(playerid,color_yellow,"sss","IP: ",GetPlayerIpEx(id),".");
- return 1;
- }
- COMMAND:whowas(playerid,params[])
- {
- new pName[MAX_PLAYER_NAME];
- if(sscanf(params,"s[32]",pName)) return SendClientMessage(playerid,color_red,"USAGE: /whowas [playername]");
- #if USE_MYSQL_DATABASE == true
- new query[128];format(query,sizeof query,"SELECT * FROM users WHERE Username = '%s'",pName);
- if(yoursql_countrows(query) != 1) return SendClientMessage(playerid,color_red,"User not found in our database!");
- format(query,sizeof query,"Username = '%s'",pName);
- sscanf(yoursql_receive("users",query),"p<|>e<s[32]s[129]iiiiis[32]>",TempInfo);
- #else
- new file[64];format(file,sizeof file,"Users/%s.ini",pName);
- if(!fexist(file)) return SendClientMessage(playerid,color_red,"User not found in our database!");
- INI_ParseFile(file, "YINI_TEMPLOAD", .bExtra = true, .extra = playerid);
- #endif
- SendClientMessageEx(playerid,color_orange,"sss","Who was ",pName,".");
- SendClientMessageEx(playerid,color_yellow,"sss","Username: {FFFFFF}",TempInfo[Username],".");
- switch(TempInfo[Level])
- {
- case 0:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Jogador.");
- case 1:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Moderador.");
- case 2:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Administrador.");
- case 3:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Owner.");
- }
- SendClientMessageEx(playerid,color_yellow,"sis","Score: ",TempInfo[Score],".");
- SendClientMessageEx(playerid,color_yellow,"sis","Money: ",TempInfo[Money],".");
- SendClientMessageEx(playerid,color_yellow,"sss","IP: ",TempInfo[Ip],".");
- format(TempInfo[Username],32," ");
- format(TempInfo[Password],192," ");
- format(TempInfo[Muted],32," ");
- format(TempInfo[Jailed],32," ");
- format(TempInfo[Score],32," ");
- format(TempInfo[Money],32," ");
- format(TempInfo[Level],32," ");
- format(TempInfo[Ip],32," ");
- return 1;
- }
- forward YINI_TEMPLOAD(playerid,Name[],Value[]);
- public YINI_TEMPLOAD(playerid,Name[],Value[])
- {
- if(!strcmp(Name,"Username")){format(TempInfo[Username],32,"%s",Value);}
- if(!strcmp(Name,"Score")){TempInfo[Score] = strval(Value);}
- if(!strcmp(Name,"Money")){TempInfo[Money] = strval(Value);}
- if(!strcmp(Name,"Level")){TempInfo[Level] = strval(Value);}
- if(!strcmp(Name,"Ip")){format(TempInfo[Ip],32,"%s",Value);}
- return 1;
- }
- COMMAND:report(playerid,params[])
- {
- new id,reason[64];
- if(sscanf(params,"is[64]",id,reason)) return SendClientMessage(playerid,color_red,"USAGE: /report [playerid] [reason]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- new counter = 0;for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerInfo[i][Level] > 0)
- {
- SendClientMessageEx(i,color_orange,"sssisssisss","Incomming report from ",PlayerInfo[playerid][Username],"(",playerid,") Reporting ",PlayerInfo[id][Username],"(",id,"), Reason: ",reason,".");
- counter++;
- }
- }
- printf("%s has reported %s (Reason:%s)",PlayerInfo[playerid][Username],PlayerInfo[id][Username],reason);
- return SendClientMessageEx(playerid,color_orange,"sis","O teu report foi enviado a todos os administradores (",counter," de momento).");
- }
- COMMAND:admins(playerid,params[])
- {
- #if ALLOW_ADMINS == false
- return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled.");
- #else
- new counter = 0;
- SendClientMessage(playerid,color_green,"Administradores online:");
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerInfo[i][Level] > 0)
- {
- SendClientMessageEx(playerid,color_orange,"s",PlayerInfo[i][Username]);
- counter++;
- }
- }
- if(counter == 0)
- {
- SendClientMessage(playerid,color_red,"Não há administradores online!");
- }
- return 1;
- #endif
- }
- COMMAND:acmds(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] == 0) return SendClientMessage(playerid,color_red,"Não tens permissão para executares esse comando!");
- SendClientMessage(playerid,color_orange,"Moderador (Level 1 and up):");
- SendClientMessage(playerid,color_yellow,"/a /countdown /whois /announce /spectate /disarm /(un)mute /(un)freeze /(un)jail /kick");
- SendClientMessage(playerid,color_orange,"Administrador (Level 2 and up):");
- SendClientMessage(playerid,color_yellow,"/veh /get /goto /giveweapon /setmoney /setscore /explode /ban /banip /annoy");
- SendClientMessage(playerid,color_orange,"Owner (Level 3):");
- SendClientMessage(playerid,color_yellow,"/setlevel /unbanip");
- return 1;
- }
- //================================================================================================================
- //Moderator commands
- COMMAND:a(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"Não tens permissão para executares esse comando!");
- new text[128];
- if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,color_red,"[USO]: /a [texto]");
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerInfo[i][Level] < 1) continue;
- SendClientMessageEx(i,color_yellow,"ssss","Adminchat: ",PlayerInfo[playerid][Username],": {FFFFFF}",text);
- }
- return 1;
- }
- COMMAND:countdown(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- if(CountDownInProgress == true) return SendClientMessage(playerid,color_red,"There is already a countdown in progress!");
- CountDownInProgress = true;
- SetTimer("countdown",1000,false);
- SendClientMessageToAllEx(color_red,"sss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} has started a countdown!");
- return 1;
- }
- forward countdown();
- public countdown()
- {
- if(countdown_counter == 0){countdown_counter = 5;CountDownInProgress = false;return GameTextForAll("GO GO GO!",1000,6);}
- new str[32];format(str,sizeof str,"~g~%i",countdown_counter);
- GameTextForAll(str,1000,6);
- countdown_counter--;
- return SetTimer("countdown",1000,false);
- }
- COMMAND:announce(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new msg[128];
- if(sscanf(params,"s",msg)) return SendClientMessage(playerid,color_red,"USAGE: /announce [text]");
- SendClientMessageToAllEx(color_yellow,"ss","ANNOUNCEMENT: ",msg);
- return GameTextForAll(msg,5000,4);
- }
- COMMAND:spectate(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /spectate [id]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(id == playerid) return SendClientMessage(playerid,color_red,"You cannot spectate yourself!");
- if(GetPVarInt(playerid,"spectating") == 1) return SendClientMessage(playerid,color_red,"You are already spectating! Please use /stop to turn spectatemode off.");
- TogglePlayerSpectating(playerid,1);
- SetPVarInt(playerid,"spectating",1);
- if(IsPlayerInAnyVehicle(id))
- {
- SetPVarInt(playerid,"state",1);
- PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
- } else {
- SetPVarInt(playerid,"state",0);
- PlayerSpectatePlayer(playerid,id);
- }
- UpdateSpectateTimer[playerid] = SetTimerEx("UpdateAdminSpectate",1000,true,"ii",playerid,id);
- return SendClientMessageEx(playerid,color_green,"sss","You are now spectating ",PlayerInfo[id][Username]," . You can use /stop to switch back to normal mode.");
- }
- forward UpdateAdminSpectate(playerid,id);
- public UpdateAdminSpectate(playerid,id)
- {
- if(GetPVarInt(playerid,"state") == 1 && !IsPlayerInAnyVehicle(id))
- {
- PlayerSpectatePlayer(playerid,id);
- SetPVarInt(playerid,"state",0);
- } else if (GetPVarInt(playerid,"state") == 0 && IsPlayerInAnyVehicle(id)) {
- PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
- SetPVarInt(playerid,"state",1);
- }
- }
- COMMAND:stop(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- if(GetPVarInt(playerid,"spectating") == 0) return SendClientMessage(playerid,color_red,"You are not spectating a player! use /spectate [ID] to spectate a player.");
- TogglePlayerSpectating(playerid,0);
- SetPVarInt(playerid,"spectating",0);
- KillTimer(UpdateSpectateTimer[playerid]);
- return 1;
- }
- COMMAND:disarm(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /disarm [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- ResetPlayerWeapons(id);
- SendClientMessageToAllEx(color_red,"ssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} disarmed ",PlayerInfo[id][Username],".");
- return 1;
- }
- COMMAND:mute(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,reason[64];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /mute [id] [reason]");
- sscanf(params,"is[64]",id,reason);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(PlayerInfo[id][Muted] == 1) return SendClientMessage(playerid,color_red,"Player is already muted!");
- if(!strlen(reason))
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username],".");
- } else {
- SendClientMessageToAllEx(color_red,"sssssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username]," Reason:",reason,".");
- }
- PlayerInfo[id][Muted] = 1;
- MutePlayer(id);
- return 1;
- }
- COMMAND:unmute(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unmute [id]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(PlayerInfo[id][Muted] == 0) return SendClientMessage(playerid,color_red,"Player is not muted!");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unmuted ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Muted] = 0;
- UnMutePlayer(playerid);
- return 1;
- }
- COMMAND:freeze(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,reason[64];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /freeze [id] [reason]");
- sscanf(params,"is[64]",id,reason);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(!strlen(reason))
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username],".");
- } else {
- SendClientMessageToAllEx(color_red,"sssssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username]," Reason:",reason,".");
- }
- TogglePlayerControllable(id,0);
- return 1;
- }
- COMMAND:unfreeze(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unfreeze [id]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unfroze ",PlayerInfo[id][Username],".");
- TogglePlayerControllable(id,1);
- return 1;
- }
- COMMAND:jail(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,reason[64];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /jail [id] [reason]");
- sscanf(params,"is[64]",id,reason);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(!strlen(reason))
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username],".");
- } else {
- SendClientMessageToAllEx(color_red,"sssssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username]," Reason:",reason,".");
- }
- PlayerInfo[id][Jailed] = 1;
- JailPlayer(id);
- return 1;
- }
- COMMAND:unjail(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unjail [id]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(PlayerInfo[id][Jailed] == 0) return SendClientMessage(playerid,color_red,"Player is not jailed!");
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} unjailed ",PlayerInfo[id][Username],".");
- PlayerInfo[id][Jailed] = 0;
- UnJailPlayer(id);
- return 1;
- }
- COMMAND:kick(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,reason[64];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /kick [id] [reason]");
- sscanf(params,"is[64]",id,reason);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(!strlen(reason))
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username],".");
- } else {
- SendClientMessageToAllEx(color_red,"sssssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username]," Reason:",reason,".");
- }
- return Kick(id);
- }
- //================================================================================================================
- //Administrator commands
- COMMAND:veh(playerid,params[])
- {
- #if ALLOW_VEH == false
- return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled.");
- #else
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new vehicle[32],c1 = -1,c2 = -1;
- if(sscanf(params,"s[24]",vehicle)) return SendClientMessage(playerid,color_red,"USAGE: /veh [vehiclename] [color1] [color2]");
- sscanf(params,"s[24]ii",vehicle,c1,c2);
- new model = GetVehicleModelIdByName(vehicle);
- if(model == 0) return SendClientMessage(playerid,color_red,"Sorry! Cannot find a vehicle with your entered vehiclename.");
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- CreateVehicle(model,x+5,y,z,0,c1,c2,-1);
- SendClientMessageEx(playerid,color_orange,"sss","You succesfully spawned a ",vehicle," !");
- printf("%s has spawned a %s.",PlayerInfo[playerid][Username],vehicle);
- return 1;
- #endif
- }
- COMMAND:get(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /get [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);x = x +2;
- SetPlayerPos(id,x,y,z);
- SendClientMessageEx(playerid,color_green,"sss","You have teleported ",PlayerInfo[id][Username]," to your position!");
- SendClientMessageEx(id,color_green,"sss","Administrador ",PlayerInfo[playerid][Username]," has teleported you to his position!");
- return 1;
- }
- COMMAND:goto(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /goto [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z);x = x +2;
- SetPlayerPos(playerid,x,y,z);
- SendClientMessageEx(playerid,color_green,"sss","You have teleported to ",PlayerInfo[id][Username],"'s position!");
- return 1;
- }
- COMMAND:giveweapon(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,weapon[32],ammo;
- if(sscanf(params,"is[32]i",id,weapon,ammo)) return SendClientMessage(playerid,color_red,"USAGE: /giveweapon [playerid] [weaponname] [ammo]");
- new wid = GetWeaponIdByName(weapon);
- if(wid == -1) return SendClientMessage(playerid,color_red,"Invalid weapon name!");
- GivePlayerWeapon(id,wid,ammo);
- SendClientMessageEx(id,color_green,"sssss","Administrador ",PlayerInfo[playerid][Username]," gave you a ",weapon,"!");
- SendClientMessageEx(playerid,color_green,"sssss","You have given ",PlayerInfo[id][Username]," a ",weapon,".");
- return 1;
- }
- COMMAND:setmoney(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,value;
- if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /setmoney [playerid] [value]");
- SetPlayerMoney(id,value);
- SendClientMessageEx(id,color_green,"sssis","Administrador ",PlayerInfo[playerid][Username]," has changed your money to ",value," !");
- SendClientMessageEx(playerid,color_green,"sssis","You have succesfully changed ",PlayerInfo[id][Username],"'s money to ",value," .");
- return 1;
- }
- COMMAND:setscore(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,value;
- if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /setscore [playerid] [value]");
- SetPlayerScore(id,value);
- SendClientMessageEx(id,color_green,"sssis","Administrador ",PlayerInfo[playerid][Username]," has changed your score to ",value," !");
- SendClientMessageEx(playerid,color_green,"sssis","You have succesfully changed ",PlayerInfo[id][Username],"'s score to ",value," .");
- return 1;
- }
- COMMAND:explode(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /explode [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z);
- CreateExplosion(x,y,z,0,5);
- CreateExplosion(x,y+3,z,0,7);
- CreateExplosion(x+3,y,z,0,8);
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} made ",PlayerInfo[id][Username]," go boom!");
- return 1;
- }
- COMMAND:ban(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,reason[64];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /ban [id] [reason]");
- sscanf(params,"is[64]",id,reason);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(!strlen(reason))
- {
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username],".");
- } else {
- SendClientMessageToAllEx(color_red,"sssssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username]," Reason:",reason,".");
- }
- return Ban(id);
- }
- COMMAND:banip(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new ip[32];if(sscanf(params,"s[32]",ip)) return SendClientMessage(playerid,color_red,"USAGE: /banip [ip]");
- new str[64];format(str,sizeof str,"banip %s",ip);
- SendRconCommand(str);
- SendClientMessageEx(playerid,color_green,"sss","You have succesfully banned ",ip," !");
- printf("%s has banned %s.",PlayerInfo[playerid][Username],ip);
- return 1;
- }
- COMMAND:annoy(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /annoy [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(cow_victim != -1) return SendClientMessage(playerid,color_red,"Sorry! It seems like your cow has already been stolen by another Administrador.");
- #if ALLOW_ANNOY == false
- return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled.");
- #else
- AnnoyPlayer(id);
- SendClientMessageToAllEx(color_red,"sssss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} has released his cow on ",PlayerInfo[id][Username]," !!!");
- SendClientMessageEx(playerid,color_green,"sss","You have released your cow on ",PlayerInfo[id][Username],"! please use /catchcow to bring him back.");
- return 1;
- #endif
- }
- COMMAND:catchcow(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- if(cow_victim == -1) return SendClientMessage(playerid,color_red,"You cannot catch the cow if it isnt released yet!");
- StopAnnoying();
- SendClientMessageToAllEx(color_red,"sss","***Administrador ",PlayerInfo[playerid][Username],"{FFFFFF} has brought his cow back to the farm!");
- return 1;
- }
- //================================================================================================================
- //Server owner commands
- COMMAND:setlevel(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 3&& !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new id,level;if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid,color_red,"USAGE: /setlevel [playerid] [level 0/3]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected.");
- if(level > 3) return SendClientMessage(playerid,color_red,"Error! You can only pick between level 0/3 (0: Player - 1: Moderator - 2: Administrator - 3: Owner)");
- if(PlayerInfo[id][Level] < level)
- {
- PlayerInfo[id][Level] = level;
- SendClientMessageEx(playerid,color_green,"sssis","You have promoted ",PlayerInfo[id][Username]," succesfully to level ",level,".");
- SendClientMessageEx(id,color_green,"sis","Congratulations! You have been promoted to level ",level,".");
- } else {
- PlayerInfo[id][Level] = level;
- SendClientMessageEx(playerid,color_green,"sssis","You have demoted ",PlayerInfo[id][Username]," succesfully to level ",level,".");
- SendClientMessageEx(id,color_green,"sis","You have been demoted to level ",level,".");
- }
- SaveUser(id);
- return 1;
- }
- COMMAND:unbanip(playerid,params[])
- {
- if(PlayerInfo[playerid][Level] < 3 ) return SendClientMessage(playerid,color_red,"You have no permission to use this command!");
- new ip[32];if(sscanf(params,"s[32]",ip)) return SendClientMessage(playerid,color_red,"USAGE: /unbanip [ip]");
- new str[64];format(str,sizeof str,"unbanip %s",ip);
- SendRconCommand(str);
- SendClientMessageEx(playerid,color_green,"sss","You have succesfully unbanned ",ip," !");
- printf("%s has unbanned %s.",PlayerInfo[playerid][Username],ip);
- return 1;
- }
- //================================================================================================================
- //stocks for admin script
- stock OnPlayerRegister(playerid,password[])
- {
- GetPlayerName(playerid,PlayerInfo[playerid][Username],MAX_PLAYER_NAME);
- WP_Hash(PlayerInfo[playerid][Password],129,password);
- PlayerInfo[playerid][Muted] = 0;
- PlayerInfo[playerid][Score] = GetPlayerScore(playerid);
- PlayerInfo[playerid][Money] = GetPlayerMoney(playerid);
- PlayerInfo[playerid][Level] = 0;
- format(PlayerInfo[playerid][Ip],32,"%s",GetPlayerIpEx(playerid));
- #if USE_MYSQL_DATABASE == true
- yoursql_insert("users","ssiiiiis",yoursql_escape_string(PlayerInfo[playerid][Username]),PlayerInfo[playerid][Password],PlayerInfo[playerid][Muted],PlayerInfo[playerid][Jailed],PlayerInfo[playerid][Score],PlayerInfo[playerid][Money],PlayerInfo[playerid][Level],PlayerInfo[playerid][Ip]);
- #else
- new string[128];format(string,sizeof string,"Users/%s.ini",PlayerInfo[playerid][Username]);
- new INI:handler = INI_Open(string);
- INI_WriteString(handler,"Username",PlayerInfo[playerid][Username]);
- INI_WriteString(handler,"Password",PlayerInfo[playerid][Password]);
- INI_WriteInt(handler,"Muted",PlayerInfo[playerid][Muted]);
- INI_WriteInt(handler,"Jailed",PlayerInfo[playerid][Jailed]);
- INI_WriteInt(handler,"Score",GetPlayerScore(playerid));
- INI_WriteInt(handler,"Money",GetPlayerMoney(playerid));
- INI_WriteInt(handler,"Level",0);
- INI_WriteString(handler,"Ip",GetPlayerIpEx(playerid));
- INI_Close(handler);
- #endif
- printf("%s has registered an account.",PlayerInfo[playerid][Username]);
- SendClientMessageToAllEx(color_green,"ss",PlayerInfo[playerid][Username]," has registered an account, welcome!");
- }
- stock LoadUser(playerid,pName[])
- {
- new identifier[64];
- #if USE_MYSQL_DATABASE == true
- format(identifier,sizeof identifier,"Username = '%s'",pName);
- sscanf(yoursql_receive("users",identifier),"p<|>e<s[32]s[129]iiiiis[12]>",PlayerInfo[playerid]);
- #else
- format(identifier,sizeof identifier,"Users/%s.ini",pName);
- INI_ParseFile(identifier, "YINI_LOAD", .bExtra = true, .extra = playerid);
- #endif
- SetPlayerScore(playerid,PlayerInfo[playerid][Score]);
- SetPlayerMoney(playerid,PlayerInfo[playerid][Money]);
- return 1;
- }
- forward YINI_LOAD(playerid,Name[],Value[]);
- public YINI_LOAD(playerid,Name[],Value[])
- {
- if(!strcmp(Name,"Username")){format(PlayerInfo[playerid][Username],32,"%s",Value);}
- if(!strcmp(Name,"Password")){format(PlayerInfo[playerid][Password],129,"%s",Value);}
- if(!strcmp(Name,"Muted")){PlayerInfo[playerid][Muted] = strval(Value);}
- if(!strcmp(Name,"Jailed")){PlayerInfo[playerid][Jailed] = strval(Value);}
- if(!strcmp(Name,"Score")){PlayerInfo[playerid][Score] = strval(Value);}
- if(!strcmp(Name,"Money")){PlayerInfo[playerid][Money] = strval(Value);}
- if(!strcmp(Name,"Level")){PlayerInfo[playerid][Level] = strval(Value);}
- if(!strcmp(Name,"Ip")){format(PlayerInfo[playerid][Ip],32,"%s",Value);}
- return 1;
- }
- stock SaveUser(playerid)
- {
- new string[320];
- #if USE_MYSQL_DATABASE == true
- format(string,sizeof string,"password = '%s', muted = %i, jailed = %i, score = %i, money = %i, level = %i, Ip = '%s'",yoursql_escape_string(PlayerInfo[playerid][Password]),PlayerInfo[playerid][Muted],PlayerInfo[playerid][Jailed],GetPlayerScore(playerid),GetPlayerMoney(playerid),PlayerInfo[playerid][Level],GetPlayerIpEx(playerid));
- new identifier[32];format(identifier,sizeof identifier,"Username = '%s'",PlayerInfo[playerid][Username]);
- yoursql_update("users",string,identifier);
- #else
- format(string,sizeof string,"Users/%s.ini",PlayerInfo[playerid][Username]);
- new INI:handler = INI_Open(string);
- INI_WriteString(handler,"Password",PlayerInfo[playerid][Password]);
- INI_WriteInt(handler,"Muted",PlayerInfo[playerid][Muted]);
- INI_WriteInt(handler,"Jailed",PlayerInfo[playerid][Jailed]);
- INI_WriteInt(handler,"Score",GetPlayerScore(playerid));
- INI_WriteInt(handler,"Money",GetPlayerMoney(playerid));
- INI_WriteInt(handler,"Level",PlayerInfo[playerid][Level]);
- INI_Close(handler);
- #endif
- }
- //================================================================================================================
- //Parts from Hiddos's annoying cow script
- stock AnnoyPlayer(playerid)
- {
- object_cow = CreateObject(16442, 0, 0, 0, 0, 0, 0);
- cow_victim = playerid;
- new Float:Pos[4];
- if(IsPlayerInAnyVehicle(cow_victim)) GetVehiclePos(GetPlayerVehicleID(cow_victim), Pos[0], Pos[1], Pos[2]);
- else GetPlayerPos(cow_victim, Pos[0], Pos[1], Pos[2]);
- Pos[0] += float(random(30) - 15);
- Pos[1] += float(random(30) - 15);
- StopObject(object_cow);
- SetObjectPos(object_cow, Pos[0], Pos[1], Pos[2] - 7.5);
- MoveObject(object_cow, Pos[0], Pos[1], Pos[2], 5.0);
- movecow_timer = SetTimer("MoveCow", 2000, true);
- }
- stock StopAnnoying()
- {
- KillTimer(movecow_timer);
- DestroyObject(object_cow); //Bai bai cow :(
- cow_victim = -1;
- }
- stock Float:GetPlayerSpeed(playerid)
- {
- new Float:x,Float:y,Float:z;
- if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
- else GetPlayerVelocity(playerid,x,y,z);
- return floatsqroot(x*x+y*y+z*z) * 48.5;
- }
- forward MoveCow();
- public MoveCow()
- {
- if(cow_victim == -1) return;
- new Float:Pos[7];
- GetObjectPos(object_cow, Pos[0], Pos[1], Pos[2]);
- if(IsPlayerInAnyVehicle(cow_victim)) GetVehiclePos(GetPlayerVehicleID(cow_victim), Pos[3], Pos[4], Pos[5]);
- else GetPlayerPos(cow_victim, Pos[3], Pos[4], Pos[5]);
- Pos[3] += float(random(10) - 5);
- Pos[4] += float(random(10) - 5);
- Pos[6] = atan( floatdiv(abs(Pos[4] - Pos[1]), abs(Pos[3] - Pos[0])) );
- if(Pos[3] < Pos[0] && Pos[4] < Pos[1]) Pos[6] += 180;
- else if(!(Pos[3] > Pos[0] && Pos[4] > Pos[1]))
- {
- Pos[6] *= float(-1);
- Pos[6] += float((Pos[3] > Pos[0] && Pos[4] < Pos[1]) ? (90) : (270));
- Pos[6] -= float(90);
- }
- SetObjectRot(object_cow, 0, 0, Pos[6]);
- MoveObject(object_cow, Pos[3], Pos[4], Pos[5] + 1.2, GetPlayerSpeed(cow_victim) + 7.8);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement