16.06.2012, 13:34
hey, i have some bugs in my script as like when i slap someone it says i have slaped myself or something
i apologise in advanced for any poor code/mistakes
pawn Код:
#include <a_samp>
#include <Dini>
#include <zcmd>
#include <sscanf2>
#define YELLOW 0xFFFF00FF
#define LIGHTBLUE 0x00FFFFFF
#define ORANGE 0xFFA500FF
#define GREY 0x808080FF
#define BLUE #0000FF
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Thefatshizms Admin System FatAdmin ");
print("--------------------------------------\n");
return 1;
}
enum gPInfo
{
Padmin,
Preg,
Ploged,
Level
}
new PInfo[MAX_PLAYERS][gPInfo];
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
PInfo[playerid][Padmin] = 0;
new name[MAX_PLAYERS], file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"FatAdmin/Users/%s.ini",name);
SetPlayerColor(playerid, LIGHTBLUE);
if(dini_Exists(file))
{
SendClientMessage(playerid, -1, "Your account has been loaded form our daterbase you may now /login");
PInfo[playerid][Preg] =1;
PInfo[playerid][Ploged] =0;
return 1;
}
if(!dini_Exists(file))
{
SendClientMessage(playerid, -1, "You need to register");
PInfo[playerid][Preg] =0;
PInfo[playerid][Ploged] =0;
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file),"FatAdmin/Users/%s.ini,name");
PInfo[playerid][Ploged] =0;
if(dini_Exists(file))
{
dini_IntSet(file,"PLoged",0);
return 1;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
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;
}
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[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
CMD:reg(playerid, params[])
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file),"FatAdmin/Users/%s.ini",name);
if(dini_Exists(file)) return SendClientMessage(playerid, -1, "You have already registered!");
if(PInfo[playerid][Preg] == 1) return SendClientMessage(playerid, -1, "you have registered!");
if(PInfo[playerid][Ploged] == 1) return SendClientMessage(playerid, -1, "you have already loged in");
if(strlen(params))
{
if(!dini_Exists(file))
{
dini_Create(file);
dini_Set(file,"password", params);
dini_IntSet(file,"Preg", 0);
dini_IntSet(file,"PLoged",0);
dini_IntSet(file,"Padmin",0);
PInfo[playerid][Preg] = 1;
return SendClientMessage(playerid, -1, "congrats you registered");
}
else
{
SendClientMessage(playerid, -1, "USAGE: /reg <password>");
return 1;
}
}
return 1;
}
CMD:login(playerid, params[])
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid,name, sizeof(name));
format(file, sizeof(file), "FatAdmin/Users/%s.ini",name);
if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
if(PInfo[playerid][Ploged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
if(PInfo[playerid][Preg] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
if(strlen(params))
{
new pass[256];
pass = dini_Get(file, "password");
if(dini_Exists(file))
{
if(strcmp(params,pass,false) != 0)
{
SendClientMessage(playerid,YELLOW,"Wrong Password!");
}
else
{
dini_IntSet(file,"Logged",1);
PInfo[playerid][Ploged] = 1;
PInfo[playerid][Level] = dini_Int(file,"Level");
SendClientMessage(playerid,YELLOW,"You have now logged in!");
return 1;
}
}
}
else
{
SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
return 1;
}
return 1;
}
CMD:acommands(playerid, params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Admin Commands", "/setlvl /kick /setscore /givewep /slap /ann /gethere /freeze /unfreeze /fine /time\n.\n.\n©Copyright Of Brennan Butler", "ok", "close");
return 1;
}
CMD:setlvl(playerid, params[])
{
new id;
new lvl;
new name[MAX_PLAYER_NAME];
new file[128];
new string[128];
new string2[128];
if(sscanf(params,"ui",id,lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlvl <id> <lvl>");
GetPlayerName(id,name,sizeof(name));
format(file, sizeof(file),"FatAdmin/Users/%s.ini",name);
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-1,"invaild id");
PInfo[id][Padmin] = lvl;
dini_IntSet(file,"Padmin", lvl);
format(string2, sizeof(string),"you have been given a admin lvl of %d by %s", lvl, name);
SendClientMessage(id, -1, string2);
format(string, sizeof(string),"you have set %s to admin level %d", name, lvl);
SendClientMessage(playerid, -1,string);
return 1;
}
CMD:kick(playerid, params[]) {
new ID, reason[24], string[128];
if(PInfo[playerid][Padmin] == 1) return true;
else if(sscanf(params,"us[24]",ID,reason)) return SendClientMessage(playerid,0xA70000FF,"Syntax: /Kick [ID] [Reason].");
format(string,sizeof(string),"You've kicked %s for reason: %s.",PlayerName(ID),reason);
SendClientMessage(playerid,0xFFFFFFFF,string);
format(string,sizeof(string),"You've been kicked by %s for reason: %s.",PlayerName(playerid),reason);
SendClientMessage(ID,0xFFFFFFFF,string);
Kick(ID);
return true;
}
stock PlayerName(playerid) {
new pName[24];
GetPlayerName(playerid,pName,24);
return pName;
}
CMD:setscore(playerid, params[])
{
new id;
new score;
new msg[128];
new msg2[128];
if(sscanf(params,"ui", id, score)) return SendClientMessage(playerid, -1, "USAGE: /setscore <id> <score>");
SetPlayerScore(id,score);
format(msg, sizeof(msg), "you have set %s score to %d", PlayerName(id), score);
format(msg2, sizeof(msg), "your score has been set by %s to score %d", PlayerName(playerid), score);
SendClientMessage(playerid, -1, msg);
SendClientMessage(id, -1, msg2);
PlayerPlaySound(id, 5450, 0, 0, 0);
PlayerPlaySound(playerid, 5201, 0, 0, 0);
return 1;
}
CMD:givewep(playerid, params[])
{
new id;
new gunid;
new wepstring[128];
new wepstring2[128];
if(sscanf(params,"ui",id,gunid)) return SendClientMessage(playerid, -1, "usage: /givewep <id> <wepid>");
GivePlayerWeapon(id, gunid, 500);
format(wepstring, sizeof(wepstring), "you have given %s a gun", PlayerName(id));
format(wepstring2, sizeof(wepstring2), "you have been given a gun by %s", PlayerName(playerid));
SendClientMessage(playerid, ORANGE, wepstring);
SendClientMessage(id, ORANGE, wepstring2);
return 1;
}
CMD:explode(playerid, params[])
{
new id;
new allstring[128];
new mestring[128];
new youstring[128];
new Float:X, Float:Y, Float:Z;
if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /explode [id]");
GetPlayerPos(id, X, Y, Z);
CreateExplosion(X, Y, Z, 0, 1);
format(allstring, sizeof(allstring), "%s has exploded %s", PlayerName(playerid), PlayerName(id));
format(mestring, sizeof(mestring), "you have exploded %s", PlayerName(id));
format(youstring, sizeof(youstring), "you have been exploded by %s", PlayerName(playerid));
SendClientMessageToAll(ORANGE, allstring);
SendClientMessage(playerid, -1, mestring);
SendClientMessage(id, -1, youstring);
return 1;
}
CMD:slap(playerid, params[])
{
new id;
new string[128];
new stringu[128];
new Float:X, Float:Y, Float:Z;
if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /slap [id]");
GetPlayerPos(id, X, Y, Z);
SetPlayerPos(id, X, Y, Z+7);
format(string, sizeof(string), "you have slaped %s", PlayerName(id));
format(stringu, sizeof(stringu), "you have been slaped by %s", PlayerName(playerid));
SendClientMessage(playerid, ORANGE, string);
SendClientMessage(playerid, -1, stringu);
return 1;
}
CMD:ann(playerid, params[])
{
new text[50];
if(sscanf(params,"s[50]",text)) return SendClientMessage(playerid, -1, "USAGE: /ann [text]");
GameTextForAll(text, 10000, 6);
return 1;
}
CMD:gethere(playerid, params[])
{
new id;
new Float:X, Float:Y, Float:Z;
new string[128];
new string2[128];
if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /gethere [id]");
GetPlayerPos(playerid, X, Y, Z);
SetPlayerPos(id, X, Y, Z);
format(string, sizeof(string), "you have teleported %s to your position", PlayerName(id));
format(string2, sizeof(string2), "you have been teleported to %s's position", PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
return 1;
}
CMD:freeze(playerid, params[])
{
new id;
new string[128];
new string2[128];
if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /freeze [id]");
TogglePlayerControllable(id, 0);
format(string, sizeof(string), "you have frozen %s", PlayerName(id));
format(string2, sizeof(string2), "you have been frozen by %s", PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
return 1;
}
CMD:unfreeze(playerid, params[])
{
new id;
new string[128];
new string2[128];
if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /unfreeze [id]");
TogglePlayerControllable(id, 1);
format(string, sizeof(string), "you have unfrozen %s", PlayerName(id));
format(string2, sizeof(string2), "you have been unfrozen by %s", PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
return 1;
}
CMD:setskin(playerid, params[])
{
new id;
new skinid;
new string[128];
new string2[128];
if(sscanf(params,"ui",id,skinid)) return SendClientMessage(playerid, -1, "USAGE: /setskin [id] [skinid]");
SetPlayerSkin(id, skinid);
format(string, sizeof(string), "you have made %s skin id %d",PlayerName(id),skinid);
format(string2, sizeof(string2), "your skin has been set to %d by %s", skinid, PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
return 1;
}
CMD:fine(playerid, params[])
{
new id;
new ammount;
new string[128];
new string2[128];
if(sscanf(params,"ui",id,ammount)) return SendClientMessage(playerid, -1, "USAGE: /fine [id] [ammount]");
GivePlayerMoney(id, -ammount);
format(string, sizeof(string), "you have fined %s $%d",PlayerName(id),ammount);
format(string2, sizeof(string2), "you have been fined by %s for $%d", PlayerName(playerid), ammount);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
return 1;
}
CMD:time(playerid, params[])
{
new time;
new string[128];
new string2[128];
if(sscanf(params,"i",time)) return SendClientMessage(playerid, -1, "USAGE: /time [00:00-23:00]");
SetWorldTime(time);
format(string, sizeof(string), "you have set the time to %d",time);
format(string2, sizeof(string2), "%s has set the time to %d", PlayerName(playerid), time);
SendClientMessage(playerid, -1, string);
SendClientMessageToAll(-1, string2);
return 1;
}
CMD:ban(playerid, params[])
{
new ID;
new reason[26];
new banmsg[128];
new done[120];
new banhim[125];
if(sscanf(params,"us[26]",ID,reason)) return SendClientMessage(playerid, -1, "USAGE /ban [id] [reason] ");
format(banmsg, sizeof(banmsg), "%s has banned %s for reason: %s", PlayerName(playerid), PlayerName(ID), reason);
format(done, sizeof(done), "you have banned %s for reason: %s", PlayerName(ID), reason);
format(banhim, sizeof(banhim), "you have been banned by %s for reason: %s", PlayerName(playerid), reason);
SendClientMessageToAll(ORANGE, banmsg);
SendClientMessage(playerid, -1, done);
SendClientMessage(ID, -1, banhim);
Ban(ID);
return 1;
}
CMD:givecar(playerid, params[])
{
new id;
new carid;
new string[128];
new string2[128];
new Float:X, Float:Y, Float:Z;
new Float:angle;
new car;
if(sscanf(params,"ui",id,carid)) return SendClientMessage(playerid, -1, "USAGE: /givecar [id] [carid]");
format(string, sizeof(string),"%s has given you a vehicle(id: %d)", PlayerName(playerid), carid);
format(string2, sizeof(string2),"you have given %s a vehicle(id: %d",PlayerName(id), carid);
GetPlayerPos(id, X, Y, Z);
GetPlayerFacingAngle(id, angle);
car = CreateVehicle(carid, X, Y, Z, angle, 0, 1, -1);
SendClientMessage(id, -1, string);
SendClientMessage(playerid, -1, string2);
PutPlayerInVehicle(id, car, 0);
return 1;
}