CMD:ban(playerid, params[]) { new id, reason[50], string[128], banned[MAX_PLAYER_NAME]; if(PlayerInfo[playerid][pAdminLevel] < 3 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not allowed to use this command."); if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason]"); GetPlayerName(id, banned, sizeof(banned)); format(string, sizeof(string), "%s has been banned by %s. reason: %s", banned, GetName(playerid), reason); SendClientMessageToAll(0xFFF03C3CFF, string); PlayerInfo[playerid][pBanned] = 1; BanEx(id, reason); return 1; }
public OnPlayerDisconnect(playerid, reason) { new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(gPlayerLogged[playerid] == 1) { dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]); dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]); dini_IntSet(file, "pBanned",PlayerInfo[playerid][pBanned]); } gPlayerLogged[playerid] = 0; new name2[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s s-a deconnectat pe server.", name2); SendClientMessageToAll(0xFFC9C9C9FF, string); return 1; }
format(file, sizeof(file), SERVER_USER_FILE, name);
Oh, I've never used BanEx so I didn't know it's a default function.
Where is the player's name in the user path? pawn Код:
|
#define SERVER_USER_FILE "Users/%s.ini"
// This is a comment // uncomment the line below if you want to a filterscript /*=====Incldues=====*/ #include <a_samp> #include <YSI\y_ini> #include <zcmd> #include <foreach> #include <dini> #include <dudb> #include <sscanf2> #pragma unused ret_memcpy /*=====Colors=====*/ #define COLOR_ACTION 0xC2A2DAAA #define COLOR_SHOUT 0xFFFFFFFF #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define COLOR_ORANGE 0xFF9900AA #define COLOR_RED 0xAA3333AA #define COLOR_YELLOW 0xFFFF00AA /*=====Dialog Defines=====*/ /*=====UserPath=====*/ enum pInfo { pAdminLevel, pCash, pScore, pBanned } new PlayerInfo[MAX_PLAYERS][pInfo]; new gPlayerLogged[MAX_PLAYERS]; #define SERVER_USER_FILE "Users/%s.ini" main() { print("G-Zone Loading.."); print("Scripted by Vuze"); print("....................."); } public OnGameModeInit() { SetGameModeText("G-Zone v0.1"); EnableStuntBonusForAll(0); DisableInteriorEnterExits(); ShowPlayerMarkers(0); CreateObject(970, 1273.07666, -1290.83569, 13.02951, 0.00000, 0.00000, 0.00000); CreateObject(970, 1277.19958, -1290.83240, 13.00014, 0.00000, 0.00000, 0.00000); CreateObject(970, 1281.31531, -1290.82422, 12.98406, 0.00000, 0.00000, 0.00000); CreateObject(970, 1285.45862, -1290.82410, 12.99049, 0.00000, 0.00000, 0.00000); CreateObject(966, 1270.31616, -1330.57764, 12.15888, 0.00000, 0.00000, 90.05998); CreateObject(966, 1270.12964, -1344.54102, 12.15794, 0.00000, 0.00000, -91.61999); CreateObject(970, 1270.28247, -1348.63562, 13.02951, 0.00000, 0.00000, -89.39999); CreateObject(970, 1270.43005, -1327.10046, 13.02951, 0.00000, 0.00000, -89.39999); CreateObject(970, 1278.78503, -1384.89990, 13.02951, 0.00000, 0.00000, -179.58005); CreateObject(970, 1282.94592, -1384.86658, 13.02951, 0.00000, 0.00000, -179.58005); CreateObject(970, 1287.14771, -1384.87183, 13.02951, 0.00000, 0.00000, -179.58005); CreateObject(970, 1274.66382, -1384.91650, 13.02951, 0.00000, 0.00000, -179.58005); CreateObject(970, 1272.56763, -1384.91858, 13.02951, 0.00000, 0.00000, -179.58005); CreateObject(970, 1289.27380, -1369.33167, 13.18856, 3.48000, 2.46000, -268.44019); return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetSpawnInfo(playerid, 0, 170,1285.5762,-1329.3383,13.5495,92.3338,0,0,0,0,0,0); // Spawn LS SpawnPlayer(playerid); return 1; } public OnPlayerConnect(playerid) { gPlayerLogged[playerid] = 0; new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if (!dini_Exists(file)) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "SERVER: Register", "Welcome to the G-Zone community.\n\nPlease register your password below.", "Register", "Leave"); } if(fexist(file)) { ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "SERVER: Login", "Welcome to the G-Zone community.\n\nPlease enter your password below.", "Login", "Leave"); } new name2[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, name2, sizeof(name2)); format(string, sizeof(string), "%s s-a connectat pe server.", name2); SendClientMessageToAll(0xFFFFB029FF, string); return 1; } public OnPlayerDisconnect(playerid, reason) { new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(gPlayerLogged[playerid] == 1) { dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]); dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]); dini_IntSet(file, "pBanned",PlayerInfo[playerid][pBanned]); } gPlayerLogged[playerid] = 0; new name2[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s s-a deconnectat pe server.", name2); SendClientMessageToAll(0xFFC9C9C9FF, string); return 1; } public OnPlayerSpawn(playerid) { SetPlayerColor(playerid, -1); return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } /*==============================Admin Commands=======================================*/ CMD:ban(playerid, params[]) { new id, reason[50], string[128], banned[MAX_PLAYER_NAME]; if(PlayerInfo[playerid][pAdminLevel] < 3) return SendClientMessage(playerid,-1,"You are not allowed to use this command."); if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason]"); GetPlayerName(id, banned, sizeof(banned)); format(string, sizeof(string), "%s has been banned by %s. reason: %s", banned, GetName(playerid), reason); SendClientMessageToAll(0xFFF03C3CFF, string); PlayerInfo[playerid][pBanned] = 1; BanEx(id, reason); return 1; } /*==============================End of Admin=======================================*/ /*==============================Regular Commands=======================================*/ CMD:factions(playerid) { ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "G-Zone Factions", "{004CFF}Politia Romana\n{004CFF}Armata Romana\n{FF8400}Paramedics\n{FFEE00}Taxi Cab Company\n{FACE9B}Tow Car Company\n{287030}The Ballas Family\n{704428}Street Racing\n{878787}Hitman\n{00CCFF}The Russian Mafia\n{AEFF00}Los Aztecas\n{91FF00}Grove Street", "Close", ""); return 1; } CMD:me(playerid, params[]) { new string[128],pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, MAX_PLAYER_NAME); if(isnull(params)) return SendClientMessage(playerid, 0x2B63CCFF, "[G-Zone]: {E6E6E6}/me [action]"); format(string, sizeof(string), "* %s %s", pname, params); ProxDetector(10.0, playerid, string, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION); return 1; } CMD:do(playerid, params[]) { new string[128],pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, MAX_PLAYER_NAME); if(isnull(params)) return SendClientMessage(playerid, 0x2B63CCFF, "[G-Zone]: {E6E6E6}/do [action]"); format(string, sizeof(string), "* %s %s", pname, params); ProxDetector(10.0, playerid, string, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION, COLOR_ACTION); return 1; } CMD:shout(playerid, params[]) { new string[128],shout[100]; if(sscanf(params, "s[100]", shout)) if(isnull(params)) return SendClientMessage(playerid, 0xFFE6E6E6FF, "USAGE: /shout [message]"); format(string, sizeof(string), "%s shouts: %s!", GetName(playerid), shout); ProxDetector(30.0, playerid, string, COLOR_SHOUT, COLOR_SHOUT, COLOR_SHOUT, COLOR_SHOUT, COLOR_SHOUT); return 1; } /*==============================End of Regular=======================================*/ public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if (dialogid == 1) { new name[MAX_PLAYER_NAME], file[256], string[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "SERVER: Register", "Welcome to the G-Zone community.\n\nPlease register your password below.", "Register", "Leave"); dini_Create(file); dini_IntSet(file, "Password", udb_hash(inputtext)); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0); dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 50000); dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0); format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext); SendClientMessage(playerid, COLOR_YELLOW, string); gPlayerLogged[playerid] = 1; } if (dialogid == 2) { new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "SERVER: Register", "Welcome to the G-Zone community.\n\nPlease register your password below.", "Login", "Leave"); new tmp; tmp = dini_Int(file, "Password"); if(udb_hash(inputtext) != tmp) { SendClientMessage(playerid, COLOR_RED, "Wrong PW sir."); ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "SERVER: Register", "Welcome to the G-Zone community.\n\nPlease enter your password below.", "Login", "Leavel"); } else { gPlayerLogged[playerid] = 1; PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel"); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid)); SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!"); if(PlayerInfo[playerid][pBanned] > 0) { SendClientMessage(playerid, 0xFFF03C3CFF, "You are banned. Please make an unban request @ http://www.g-zone.ro"); Kick(playerid); return 1; } if(PlayerInfo[playerid][pAdminLevel] > 0) { SendClientMessage(playerid, -1, "You are an admin!"); return 1; } } } return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; } forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5); public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5) { if(IsPlayerConnected(playerid)) { new Float:posx, Float:posy, Float:posz; new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))) { GetPlayerPos(i, posx, posy, posz); tempposx = (oldposx -posx); tempposy = (oldposy -posy); tempposz = (oldposz -posz); if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) // If the player is within 16 meters { SendClientMessage(i, col1, string); } else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) // within 8 meters { SendClientMessage(i, col2, string); } else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) //4 meters { SendClientMessage(i, col3, string); } else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) //2 meters { SendClientMessage(i, col4, string); } else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) //1 meter { SendClientMessage(i, col5, string); } } else { SendClientMessage(i, col1, string); } } } return 1; } stock GetName(playerid) { new name[24]; GetPlayerName(playerid, name, sizeof(name)); return name; }