17.06.2010, 20:23
Код:
// // FS de Admin Hernan_ER // #include <a_samp> #include "../include/gl_common.inc" #define MAX_WARNINGS 3 #define COLOR_VERDE 0x26b22dAA #define COLOR_ROJO 0xb22626AA #define COLOR_AMARILLO 0xb2ad26AA #define COLOR_CELESTE 0x2689b2AA #define COLOR_BLANCO 0xFFFFFFAA #define ADMINFS_MESSAGE_COLOR 0xFF444499 #define PM_INCOMING_COLOR 0xFFFF22AA #define PM_OUTGOING_COLOR 0xFFCC2299 //Menus new Menu:Clima, Menu: Hora; // DCMD #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 // Enums enum PlayerData { Muted, Warnings, }; new PlayerInfo[MAX_PLAYERS][PlayerData]; //------------------------------------------------ public OnFilterScriptInit() { Hora = CreateMenu("~g~Hora", 2, 55.0, 200.0, 100.0, 80.0); SetMenuColumnHeader(Hora, 0, "Cambiar hora"); AddMenuItem(Hora, 0, "Maсana"); AddMenuItem(Hora, 0, "Mediodнa"); AddMenuItem(Hora, 0, "Tarde"); AddMenuItem(Hora, 0, "Atardecer"); AddMenuItem(Hora, 0, "Medianoche"); AddMenuItem(Hora, 0, "Salir"); Clima = CreateMenu("~g~Climas",2, 55.0, 200.0, 100.0, 80.0); SetMenuColumnHeader(Clima, 0, "Cambiar clima"); AddMenuItem(Clima, 0, "Despejado"); AddMenuItem(Clima, 0, "Tormenta de arena"); AddMenuItem(Clima, 0, "Tormenta electrica"); AddMenuItem(Clima, 0, "Nublado"); AddMenuItem(Clima, 0, "Niebla"); AddMenuItem(Clima, 0, "Lluvia"); AddMenuItem(Clima, 0, "Verde"); AddMenuItem(Clima, 0, "Blanco y negro"); AddMenuItem(Clima, 0, "Oscuro"); AddMenuItem(Clima, 0, "Soleado"); AddMenuItem(Clima, 0, "Caluroso"); AddMenuItem(Clima, 0, "Brilloso"); AddMenuItem(Clima,0,"Salir"); print("\n--Admin FS.\n"); return 1; } public OnPlayerConnect(playerid) { PlayerInfo[playerid][Muted] = 0; PlayerInfo[playerid][Warnings] = 0; return 1; } //------------------------------------------------ dcmd_hora(playerid,params[]) { #pragma unused params if(IsPlayerAdmin(playerid)) { if(IsPlayerInAnyVehicle(playerid)) { TogglePlayerControllable(playerid,false); return ShowMenuForPlayer(Hora,playerid); } else return ShowMenuForPlayer(Hora,playerid); } else return SendClientMessage(playerid,COLOR_ROJO,"No sos administrador."); } dcmd_clima(playerid,params[]) { #pragma unused params if(IsPlayerAdmin(playerid)) { if(IsPlayerInAnyVehicle(playerid)) { TogglePlayerControllable(playerid,false); return ShowMenuForPlayer(Clima,playerid); } else return ShowMenuForPlayer(Clima,playerid); } else return SendClientMessage(playerid,COLOR_ROJO,"No sos administrador."); } dcmd_slap(playerid,params[]) { if(IsPlayerAdmin(playerid)) { new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); if(!strlen(params)) return SendClientMessage(playerid, COLOR_ROJO, "USO: /slap [playerid] [reason/with]"); new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128]; player1 = strval(tmp); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID ) { GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname)); // CMDMessageToAdmins(playerid,"SLAP"); new Float:Health, Float:x, Float:y, Float:z; GetPlayerHealth(player1,Health); SetPlayerHealth(player1,Health-25); GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+5); PlayerPlaySound(playerid,1190,0.0,0.0,0.0); PlayerPlaySound(player1,1190,0.0,0.0,0.0); if(strlen(tmp2)) { // format(string,sizeof(string),"You have been slapped by Administrador %s %s ",adminname,params[2]); SendClientMessage(player1,red,string); format(string,sizeof(string),"You have slapped %s. Razуn: %s ",playername,params[2]); return SendClientMessage(playerid,COLOR_CELESTE,string); } else { // format(string,sizeof(string),"You have been slapped by Administrador %s ",adminname); SendClientMessage(player1,red,string); format(string,sizeof(string),"You have slapped %s",playername); return SendClientMessage(playerid,COLOR_CELESTE,string); } } else return SendClientMessage(playerid, COLOR_ROJO, "Player is not connected or is the highest level admin"); } else return SendClientMessage(playerid,COLOR_ROJO,"ERROR: You are not a high enough level to use this command"); } dcmd_announce(playerid,params[]) { if(IsPlayerAdmin(playerid)) { if(!strlen(params)) return SendClientMessage(playerid,COLOR_BLANCO,"USO: /announce <texto>"); // CMDMessageToAdmins(playerid,"ANNOUNCE"); return GameTextForAll(params,4000,3); } else return SendClientMessage(playerid,COLOR_ROJO,"No sos administrador."); } dcmd_warn(playerid,params[]) { if(IsPlayerAdmin(playerid)) { new tmp[256], tmp2[256], Index,pName[MAX_PLAYER_NAME]; tmp = strtok(params,Index), tmp2 = strtok(params,Index); if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, COLOR_ROJO, "USO: /warn [playerid] [razon]"); new warned = strval(tmp), str[128]; if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) { if(warned != playerid) { PlayerInfo[warned][Warnings]++; if( PlayerInfo[warned][Warnings] == MAX_WARNINGS) { format(str, sizeof (str), "***Administrador \"%s\" ha expulsado a \"%s\". (Razуn: %s) (Advertencias: %d/%d)***", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS); SendClientMessageToAll(COLOR_ROJO, str); return PlayerInfo[warned][Warnings] = 0; } else { format(str, sizeof (str), "***Administrador \"%s\" ha dado una advertencia a \"%s\". (Razуn: %s) (Advertencias: %d/%d)***", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS); return SendClientMessageToAll(COLOR_AMARILLO, str); } } else return SendClientMessage(playerid, COLOR_ROJO, "ERROR: You cannot warn yourself"); } else return SendClientMessage(playerid, COLOR_ROJO, "ERROR: Player is not connected"); } else return SendClientMessage(playerid,COLOR_ROJO,"No sos administrador"); } //============================================================================== // Menus //============================================================================== //#if defined USE_MENUS public OnPlayerSelectedMenuRow(playerid, row) { new Menu:Current = GetPlayerMenu(playerid); if(Current == Hora) { new adminname[MAX_PLAYER_NAME]; GetPlayerName(playerid, adminname, sizeof(adminname)); switch(row) { case 0: { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SetPlayerTime(i,7,0); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 1: { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SetPlayerTime(i,12,0); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 2: { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SetPlayerTime(i,16,0); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 3: { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SetPlayerTime(i,20,0); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 4: { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SetPlayerTime(i,0,0); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 5: { HideMenuForPlayer(Clima,playerid); TogglePlayerControllable(playerid,true); } } return TogglePlayerControllable(playerid,true); } if(Current == Clima) { new adminname[MAX_PLAYER_NAME]; GetPlayerName(playerid, adminname, sizeof(adminname)); switch(row) { case 0: { SetWeather(5); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 1: { SetWeather(19); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 2: { SetWeather(8); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 3: { SetWeather(20); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 4: { SetWeather(9); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 5: { SetWeather(16); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 6: { SetWeather(45); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 7: { SetWeather(44); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 8: { SetWeather(22); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 9: { SetWeather(11); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 10: { SetWeather(17); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 11: { SetWeather(36); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } case 12: { HideMenuForPlayer(Clima,playerid); TogglePlayerControllable(playerid,true); } } return TogglePlayerControllable(playerid,true); } return 1; } stock IsNumeric(string[]) { for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') return 0; } return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(hora,4,cmdtext); dcmd(clima,5,cmdtext); dcmd(announce,8,cmdtext); dcmd(slap,4,cmdtext); dcmd(warn,4,cmdtext); return 1; }