rendered paste body/*
--------------------------------------------------------
Mabako's admin script - RC 4.5 23/06/2006
contact mabako at IRC:
irc.gtanet.com #mn
217.20.122.51 #mn
--------------------------------------------------------
Script improved and modified by yellowblood
contact at IRC:
irc.quakenet.org #sa-mp.il ( irc://irc.quakenet.org/sa-mp.il )
contact at MSN Messenger:
yellowblood@gmail.com
-------
Changes from original version:
/goto [playername] - Teleports the admin to a player. Doesn't work well if one of them is in an interior =[
/get [playername] - Teleports a player to the admin. same as above.
You can't use /get on an admin with an higher level than yours.
/jail [playername] [reason ID / reason] - Jails player, and tell him what he shouldn't do.
Example: "do not flame", "do not annoy the admins", "obey the admins", "do not kill your teammates"
The reason will be shown as a Game Text message (same as announce) to the jailed player.
Any admins will see the reason in the chat window.
Shortcuts for the popular commands (all works great):
Quote
/j /unj /f /unf /k /b (jail, freeze, kick, ban
/getl /gm /gw (getlevel, givemoney, giveweapon
/ann /cd /ad (announce, countdown, admins
Bans - bans are getting saved with the reason (if given) and the name of the admin.
Example:
---------- [THH]Dalmo (nazism, by BlindSpot[S.A.S])
---------- Alik (lang, by kuskus)
---------- DNA (cheating, by BlindSpot[S.A.S])
---------- *_* (money cheater, by popcorn)
---------- NoneNick (by BlindSpot[S.A.S])
---------- __ (known cheater, by popcorn)
---------- Mr. (by BlindSpot[S.A.S])
---------- ALBeRTo (cheating, by Bgob)
---------- giga (regen armor, by Shir)
Admins chat:
Private chat for level 2 and above admins or RCON ones.
There are 2 ways to admins chat: @text and //text.
The second way will always work.
The first way requirs a simple modification on any gamemode - add those lines:
---------- public OnPlayerText(playerid,text[])
---------- {
---------- if (text[0] == '@') return 0;
---------- return 1;
---------- }
Admins can see private messages and commands written by regular players.
Commands Jail, Freeze, and Disarm are now private:
Regular players will see the message "playername frozen/jailed/disarmed by an admin"
while admins will see the message "playername frozen/jailed/disarmed by adminname"
You can use /announce (or /ann) without writing the number of seconds - the message will be shown for 15 seconds by default.
Admins can use commands on themselfs and on other admins on the same level.
An admin that isn't rcon, can't use any commands on an rcon admin.
/help command changed:
If you type "/help", it will give a one line message -
"For help about the registration script, write /shelp.", and
will NOT interrupt the help commands of the gamemodes.
/lock command changed:
I never realy used it, but I found it realy annoying when you play
in some modes that let you lock your car. The command is now "/lockserv".
--------------------------------------------------------
*/
#include <a_samp>
#include <file>
#include <string>
#include <dprop>
#define COLOR_WHITE 0xFFFFFFAA // white
#define COLOR_YELLOW 0xFFFF00AA // yellow
#define COLOR_BLUE 0x33CCFFAA // blue
#define COLOR_RED 0xAA3333AA // red
#define COLOR_GREEN 0x33AA33FF // green
#define COLOR_GREY 0xAFAFAFAA // grey
#define COLOR_LIGHTBLUE 0x33CCFFAA //light blue
#define COLOR_ORANGE 0xFF9900AA
//new WorldTimeTimer = -1;
new version_a[11] = "0.1 RC 4.5";
new version_b[4] = "145";
new Level[MAX_PLAYERS];
new Name[MAX_PLAYERS][MAX_PLAYER_NAME];
new FailedLogins[MAX_PLAYERS];
new OnlinePlayers[MAX_PLAYERS];
new num_online_players;
new jailed[MAX_PLAYERS]; // Tracks if player is jailed
new lines[MAX_PLAYERS];
new linestimer;
new antispam_time = 30;
new antispam_lines = 10;
new antispam_ignore = 0;
/* CL = CommandLevel
Levels you need for the command */
new CL_login = -1;
new CL_register = -1;
new CL_ghost = -1;
new CL_me = -1;
new CL_getlevel = -1;
new CL_changepass = -1;
new CL_jail = -1;
new CL_freeze = -1;
new CL_kick = -1;
new CL_kill = -1;
new CL_givemoney = -1;
new CL_giveweapon = -1;
new CL_disarm = -1;
new CL_sethealth = -1;
new CL_end = -1;
new CL_ban = -1;
new CL_clanban = -1;
new CL_clankick = -1;
new CL_setlevel = -1;
new CL_tmplevel = -1;
new CL_clear = -1;
new CL_announce = -1;
new CL_admins = -1;
new CL_countdown = -1;
new CL_lock = -1;
new CL_slap = -1;
new CL_acread = -1;
new CL_acwrite = -1;
new CL_pms = -1;
new CL_cmds = -1;
new player_lock;
new slap_takehealth = 0;
new debugmode = 0;
new newkick = 0;
new kicktime[MAX_PLAYERS];
//kick timer off. new kicktimer;
new countdown_seconds;
new countdown_timer;
new countdown_freeze = 0;
/* Configuration */
new servername[256] = "xxx";
new onspawnaction[256];
new onspawnhealth;
new onspawnlevel;
new default_language;
new PlayerLanguage[MAX_PLAYERS];
new langshortcut[256];
new use_prefix;
/* ----------------------------------------------------
// RACES
// ----------------------------------------------------
#define MAX_RACES 1
#define NO_RACE 0
#define RACE_A 1 //big race all over san andreas
#define RACE_B 2 //LV tour
#define RACE_C 3 //Country tour
#define RACES_CP_SIZE 20.0
#define PRIZE 10000
new rcsPlayerPrograss[MAX_PLAYERS];
new rcsFlag = NO_RACE;
new rcsCPNum[2] = {0,19};
new rcsWinners[3] = {255, 255, 255};
new rcsNameA[MAX_PLAYER_NAME];
new rcsNameB[MAX_PLAYER_NAME];
new rcsNameC[MAX_PLAYER_NAME];
#define MAX_RACE_A 19
//new ALL_ZONE_X[4] = {-5000,-5000,5000,5000}; //cords
new Float:race_a_cps[MAX_RACE_A][4] = {
{1977.554809, 841.672668, 6.711115, 20.0}, // 1
{1797.336547, 823.829406, 10.636805, 20.0}, // 2
{1625.210083, 166.189407, 34.601322, 20.0}, // 3 (highway country)
{1602.026855, -1369.316040, 28.771766, 20.0}, // 4 cross road LS
{1330.954101, -2365.918212, 13.375000, 20.0}, // 5 (turn right near LS airport)
{1199.813110, -2434.420410, 9.978971, 20.0}, // 6
{419.405364, -1710.530517, 9.468660, 20.0}, // 7 LS beach
{-166.612213, -1497.793701, 13.176724, 20.0}, // 8 (highway to SF)
{-99.172302, -2804.531494, 38.720886, 20.0}, // 9
{-1194.573608, -2861.382812, 67.934425, 20.0}, // 10
{-2531.070556, -2150.094970, 30.561614, 20.0}, // 11 (tunnel)
{-2888.786132, -1044.157470, 9.492187, 20.0}, // 12 (bridge)
{-2019.774169, -323.446594, 35.219802, 20.0}, // 13 (SF crossroad)
{-1659.501220, 552.928222, 38.924137, 20.0}, // 14 (SF bridge)
{-1062.893066, 1170.804199, 38.716171, 20.0}, // 15
{-605.201660, 642.084289, 16.828769, 20.0}, // 16 (LV bridge)
{471.942077, 728.091857, 5.229682, 20.0}, // 17
{1136.917236, 817.198059, 10.631628, 20.0}, // 18 (getting in LV)
{2039.877319, 842.912170, 6.703125, 20.0} // 19 (finish line)
}; */
public OnFilterScriptInit() {
print("\n |--AdminSystem by mabako (improved and modified by yellowblood) loaded.");
printf(" |--Version: %s\n",version_a);
ReadConfig();
print(" Enabled Options: ");
printf(" |--Servername = %s",servername);
printf(" |--OnSpawnAction = %s",onspawnaction);
printf(" |--OnSpawnHealth = %d",onspawnhealth);
printf(" |--OnSpawnLevel = %d",onspawnlevel);
langshortcut = GetLanguageShortcut(default_language);
printf(" |--Default Lang. = %s (Shortcut: %s | Language id %d)",GetLanguageFull(default_language),langshortcut,default_language);
new temp[4];
if(use_prefix == 1) temp = "en";
else temp = "dis";
printf(" |--Command prefixes = %sabled",temp);
if(debugmode == 1) print(" |--debug mode = enabled");
if(antispam_ignore == 0) temp = "dis";
else temp = "en";
printf(" |--Spam Protection = %sabled",temp);
if(!PropertyExists("mn-version")) PropertySet("mn-version",version_b);
// SetTimer("rcsUpdateCheckpoints()", 500, 1);
}
public OnFilterScriptExit() {
print("\n |--AdminSystem unloaded.");
print(" |--Visit www.mabako.net\n");
}
/* Script function section */
public OnPlayerCommandText(playerid, cmdtext[])
{
//admins chat
if(cmdtext[1] == '/' && CL_acwrite != -1 && CL_acread != -1)
{
Admins_Chat(playerid, cmdtext);
return 1;
}
if(jailed[playerid] == 1 && !IsPlayerAdmin(playerid))
JailPlayer(playerid);
ReadConfig();
new command[256];
new index;
new temp[256];
new temp2[256];
command = admin_strtok(cmdtext, index);
if(use_prefix == 0 && strlen(command) > 1) {
index = 1;
command = admin_strtok(cmdtext, index);
}
else if(use_prefix == 1 && strcmp(firstchars(command,4),"/mn-",true) == 0 && strlen(command) > 4) {
index = 4;
command = admin_strtok(cmdtext, index);
}
else {
return 0;
}
new year,month,day;
getdate(year, month, day);
new hour,minute,second;
gettime(hour, minute, second);
new qwertz[20];
format(qwertz,sizeof(qwertz),"qwertz%d%d%d",day,month,year);
// 16/06/2006 => 1662006
// 1/3/2006 => 132006
if(debugmode == 1) {
printf("(%d/%d/%d %d:%d:%d) User: %s -- Command: %s",day,month,year,hour,minute,second,Name[playerid],cmdtext);
}
/* show commands to admins*/
if(Level[playerid] <= 1 && strcmp(command, "login", true) != 0 && strcmp(command, "register", true) != 0 && CL_cmds != -1)
{
new pname[256], cmdstring[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(cmdstring, sizeof(cmdstring), "*** %s: %s",pname, cmdtext);
for(new j = 0; j < MAX_PLAYERS; j++)
if(IsPlayerConnected(j) && (Level[j] >= CL_cmds))
SendClientMessage(j, 0x66CCCC, cmdstring);
}
if (strcmp(command, "help", true) == 0)
{
GetHelp(playerid, "half-help",0);
return 0;
}
if (strcmp(command, "shelp", true) == 0)
{
/* if(Level[playerid] == 0) GetHelp(playerid,"help",0);
else GetHelp(playerid,"help",0);*/
temp = GetHelp(playerid,"help1",1);
new thisline;
new prefix[6];
if(use_prefix == 1) prefix = "/mn-";
else prefix = "/";
new xprefix[6];
if(use_prefix == 1) { xprefix = prefix; } else { xprefix = "/0"; } // For /kill
if(Level[playerid] == CL_login && CL_login != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"login"); thisline++; }
if(Level[playerid] == CL_register && CL_register != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"register"); thisline++; }
if(Level[playerid] >= CL_ghost && CL_ghost != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"ghost"); thisline++; }
if(Level[playerid] >= CL_me && CL_me != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"me"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_slap && CL_slap != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"slap"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_getlevel && CL_getlevel != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"getlevel"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_changepass && CL_changepass != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"changepass"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_jail && CL_jail != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"jail"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_jail && CL_jail != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"unjail"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_freeze && CL_freeze != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"freeze"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_freeze && CL_freeze != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"unfreeze"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_kick && CL_kick != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"kick"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_kill && CL_kill != -1) { format(temp,sizeof(temp),"%s %s%s",temp,xprefix,"kill"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_givemoney && CL_givemoney != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"givemoney"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_giveweapon && CL_giveweapon != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"giveweapon"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_disarm && CL_disarm != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"disarm"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_sethealth && CL_sethealth != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"sethealth"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_end && CL_end != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"end"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_ban && CL_ban != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"ban"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_clanban && CL_clanban != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"clanban"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_clankick && CL_clankick != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"clankick"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_setlevel && CL_setlevel != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"setlevel"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_tmplevel && CL_tmplevel != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"tmplevel"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_clear && CL_clear != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"clear"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_announce && CL_announce != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"announce"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_admins && CL_admins != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"admins"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_countdown && CL_countdown != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"countdown"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= CL_lock && CL_lock != -1) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"lockserv"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= 2) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"shortcuts"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= 2) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"goto"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(Level[playerid] >= 2) { format(temp,sizeof(temp),"%s %s%s",temp,prefix,"get"); thisline++; if(thisline % 5 == 0) { SendClientMessage(playerid, COLOR_WHITE,temp); temp = GetHelp(playerid,"help2",1);} }
if(thisline % 5 > 0) { SendClientMessage(playerid, COLOR_WHITE,temp);}
GetHelp(playerid,"help");
printf(" |--help > %s > Level %d",Name[playerid],Level[playerid]);
return 1;
}
else if (strcmp(command, "info", true) == 0)
{
format(temp,sizeof(temp),GetHelp(playerid,"info-running",1),version_a);
SendClientMessage(playerid,COLOR_WHITE,temp);
GetHelp(playerid,"info-encrypted");
return 1;
}
else if (strcmp(command, "shortcuts", true) == 0 && Level[playerid] > 1)
{
// format(temp,sizeof(temp),");
SendClientMessage(playerid,COLOR_RED,"Commands shortcuts:");
SendClientMessage(playerid,COLOR_WHITE,"/j /unj /f /unf /k /b (jail, freeze, kick, ban)");
SendClientMessage(playerid,COLOR_WHITE,"/getl /gm /gw (getlevel, givemoney, giveweapon)");
SendClientMessage(playerid,COLOR_WHITE,"/ann /cd /ad (announce, countdown, admins)");
return 1;
}
else if (strcmp(command, "login", true) == 0 && CL_login != -1 && Level[playerid] == 0)
{
new username[256],pass[256],index2 = 0,xlevel[256],loginok = 0,password2[256],password;
// new language[256];
password2 = admin_strtok(cmdtext, index);
password = admin_hash(password2);
if(!strlen(password2)) { GetHelp(playerid,"login-help"); return 1; }
new File:fhandle;
fhandle = fopen("users.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
username = admin_strtok(temp,index2);
pass = admin_strtok(temp,index2);
if(strcmp(username,Name[playerid],true) == 0 && strval(pass) == password) {
loginok = 1;
xlevel = admin_strtok(temp,index2);
Level[playerid] = strval(xlevel);
SetLevel(playerid,strval(xlevel));
// language = admin_strtok(temp,index2);
// print(admin_strtok(temp,index2));
format(temp2,sizeof(temp2),GetHelp(playerid,"login-ok",1),Level[playerid]);
SendClientMessage(playerid,COLOR_WHITE,temp2);
if(Level[playerid] > 1) //naab
{
// SendClientMessage(playerid,COLOR_WHITE,"NOTE: Hey admins, I added some commands shortcuts, type /shortcuts for a list. [yellowblood]");
// SendClientMessage(playerid,COLOR_WHITE,"Now, there are also reasons IDs for the ban commands. Type /ban for more info. (yellowblood)");
}
printf(" |--login successful > %s",Name[playerid]);
// PlayerLanguage[playerid] = GetLanguageId(xlang);
return 0;
}
}
fclose(fhandle);
if(loginok == 0) {
FailedLogins[playerid]++;
if(FailedLogins[playerid] == 3) {
// GetHelp(playerid,"login-kick"); // kickmessage broken
printf(" |--login fail-kick > %s",Name[playerid]);
Level[playerid] = 0;
SetLevel(playerid,0);
// SetKick(playerid,GetHelp(playerid,"kick-loginfailed",1));
Kick(playerid);
} else {
GetHelp(playerid,"login-failed");
printf(" |--login failed > %s",Name[playerid]);
Level[playerid] = 0;
SetLevel(playerid,0);
}
}
return 1;
}
else if (strcmp(command, "goto", true) == 0 && Level[playerid] >= 2)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"goto-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(lookupid, x, y, z);
GetPlayerFacingAngle(lookupid, a);
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, x, y, z + 5);
SetCameraBehindPlayer(playerid);
return 1;
}
else if (strcmp(command, "get", true) == 0 && Level[playerid] >= 2)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid))
{
GetHelp(playerid,"get-help");
return 1;
}
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(playerid != lookupid && Level[playerid] >= Level[lookupid])
{
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
SetPlayerInterior(lookupid, 0);
SetPlayerPos(lookupid, x, y, z + 5);
SetCameraBehindPlayer(lookupid);
}
else
SendClientMessage(playerid, COLOR_WHITE, "No.");
return 1;
}
else if (strcmp(command, "ghost", true) == 0 && CL_ghost != -1 && Level[playerid] >= CL_ghost)
{
new xusername[256],password2[256],password,pass[256],index2 = 0,ghostok = 0,username[256];
xusername = admin_strtok(cmdtext, index);
password2 = admin_strtok(cmdtext, index);
password = admin_hash(password2);
if(!strlen(xusername) || !strlen(password2)) { GetHelp(playerid,"ghost-help"); return 1; }
new File:fhandle;
fhandle = fopen("users.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
username = admin_strtok(temp,index2);
pass = admin_strtok(temp,index2);
if(strcmp(username,xusername,true) == 0 && strval(pass) == password) {
ghostok = 1;
break;
}
}
fclose(fhandle);
if(ghostok == 0) {
format(temp,sizeof(temp),GetHelp(playerid,"ghost-failed",1),xusername);
SendClientMessage(playerid,COLOR_WHITE,temp);
printf(" |--ghost failed > %s",xusername);
} else {
printf(" |--ghost successful > %s > %s",Name[playerid],xusername);
new lookupid;
if(NameLookup(playerid,xusername,lookupid,1) != 1) return 1;
// format(temp,sizeof(temp),GetHelp(playerid,"kick-ghost",1),Name[playerid]);
// print("debug label #1");
// SetKick(lookupid,temp);
Kick(lookupid);
// print("debug label #2");
}
return 1;
}
else if (strcmp(command, "register", true) == 0 && CL_register != -1 && Level[playerid] == 0)
{
new password,password2[256];
password2 = admin_strtok(cmdtext, index);
password = admin_hash(password2);
if(!strlen(password2)) { GetHelp(playerid,"register-help"); return 1; }
new username[256],loginok = 0,index2 = 0;
new File:fhandle;
fhandle = fopen("users.txt",io_read);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
username = admin_strtok(temp,index2);
if(strcmp(username,Name[playerid],true) == 0) {
GetHelp(playerid,"register-already-done");
printf(" |--registration failed > %s",Name[playerid]);
loginok = 1;
break;
}
}
fclose(fhandle);
if(loginok == 0) {
// new File:fhandle;
format(temp,sizeof(temp),"%s %d 1 %s\r\n",Name[playerid],password,GetLanguageShortcut(PlayerLanguage[playerid]));
fhandle = fopen("users.txt",io_append);
fwrite(fhandle,temp);
fclose(fhandle);
Level[playerid] = 1;
SetLevel(playerid,1);
GetHelp(playerid,"register-ok");
printf(" |--register > %s",Name[playerid]);
}
return 1;
}
else if ((strcmp(command, "ad", true) == 0 || strcmp(command, "admins", true) == 0) && CL_admins != -1 && Level[playerid] >= CL_admins)
{
new thisline = 0;
new admins_online = 0;
temp = GetHelp(playerid,"admins1",1);
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(Level[i] >= 2) {
format(temp,sizeof(temp),"%s %s(%d)",temp,Name[i],Level[i]);
admins_online++;
thisline++;
if(thisline == 4) {
SendClientMessage(playerid, COLOR_WHITE,temp);
temp = GetHelp(playerid,"admins2",1);
thisline = 0;
}
}
}
}
if(thisline >= 1) SendClientMessage(playerid, COLOR_WHITE,temp);
if(admins_online == 0) {
GetHelp(playerid,"admins-none");
}
return 1;
}
else if (strcmp(command,"changepass",true) == 0 && CL_changepass != -1 && Level[playerid] >= CL_changepass && Level[playerid] >= 1) // Hard coded limit else you can change pw without login
{
new x_password_old[256],x_password_new1[256],x_password_new2[256],password_new,password_old;
x_password_old = admin_strtok(cmdtext, index);
password_old = admin_hash(x_password_old);
x_password_new1 = admin_strtok(cmdtext, index);
password_new = admin_hash(x_password_new1);
x_password_new2 = admin_strtok(cmdtext, index);
if(!strlen(x_password_old) || !strlen(x_password_new1) || !strlen(x_password_new2)) { GetHelp(playerid,"changepass-help"); return 1; }
if(strcmp(x_password_new1,x_password_new2,true) != 0) { GetHelp(playerid,"changepass-wrong-repeat"); return 1; }
//fcopy("users.txt","users.tmp");
frename("users.txt","users.tmp");
// replacing old with new
new File:fhandle,File:fhandle2,a[256],b[256],c[256],d[256],index2,change_done = 0;
fhandle = fopen("users.tmp",io_read);
fhandle2 = fopen("users.txt",io_write);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
a = admin_strtok(temp,index2);
b = admin_strtok(temp,index2);
c = admin_strtok(temp,index2);
d = admin_strtok(temp,index2);
if(strcmp(a,Name[playerid], true) == 0 && strval(b) == password_old) {
format(temp2,sizeof(temp2),"%s %d %s %s\r\n",Name[playerid],password_new,c,d);
fwrite(fhandle2,temp2);
change_done = 1;
}
else {
fwrite(fhandle2,temp);
}
}
fclose(fhandle);
fclose(fhandle2);
// k done
if(change_done == 1) {
GetHelp(playerid,"changepass-ok");
format(temp2,sizeof(temp2)," |--changepass successful > %s",Name[playerid]);
print(temp2);
}
else
{
GetHelp(playerid,"changepass-failed");
format(temp2,sizeof(temp2)," |--changepass failed > %s",Name[playerid]);
print(temp2);
}
return 1;
}
else if (strcmp(command, "me", true) == 0 && CL_me != -1 && Level[playerid] >= CL_me)
{
temp = admin_strrest(cmdtext, index+1);
if(!strlen(temp)) { GetHelp(playerid,"me-help"); return 1; }
//format(temp2,sizeof(temp2),"%s %s",Name[playerid],temp);
format(temp2,sizeof(temp2),GetHelp(playerid,"me-text",1),Name[playerid],temp);
SendClientMessageToAll(COLOR_BLUE,temp2);
printf(" |--me > %s > %s",Name[playerid],temp);
return 1;
}
else if (strcmp(command, "slap", true) == 0 && CL_slap != -1 && Level[playerid] >= CL_slap)
{
temp = admin_strrest(cmdtext, index+1);
if(!strlen(temp)) { GetHelp(playerid,"slap-help"); return 1; }
new lookupid;
if(NameLookup(playerid,temp,lookupid,1) != 1) return 1;
format(temp2,sizeof(temp2),GetHelp(playerid,"slap-text",1),Name[playerid],Name[lookupid]);
SendClientMessageToAll(COLOR_BLUE,temp2);
//SendClientMessageToAll(GetPlayerColor(playerid),temp2);
printf(" |--slap > %s > %s",Name[playerid],Name[playerid]);
if(Level[playerid] >= 2 && Level[playerid] > Level[lookupid] && slap_takehealth > 0) { // Takes a bit of health away
new Float:oldhealth, health;
GetPlayerHealth(lookupid,oldhealth);
format(temp,sizeof(temp),"%f",oldhealth);
health = strval(temp);
health -= slap_takehealth;
if(health < 1) health = 1;
SetPlayerHealth(lookupid,float(health));
}
return 1;
}
else if ((strcmp(command, "getl", true) == 0 || strcmp(command, "getlevel", true) == 0) && CL_getlevel != -1 && Level[playerid] >= CL_getlevel)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"getlevel-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
valstr(temp,Level[lookupid]);
SuccessMessage(playerid,lookupid,command,"",temp,1);
format(temp2,sizeof(temp2),GetHelp(playerid,"getlevel-output",1),Name[lookupid],Level[lookupid]);
SendClientMessage(playerid,COLOR_WHITE,temp2);
return 1;
}
else if ((strcmp(command, "j", true) == 0 || strcmp(command, "jail", true) == 0) && CL_jail != -1 && Level[playerid] >= CL_jail)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"jail-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SuccessMessage(playerid,lookupid,command,"jailed");
JailPlayer(lookupid);
new reason[256];
reason = admin_strrest(cmdtext, index);
if(strlen(reason) > 0)
{
printf(" ----jail reason: %s",reason);
new jtext[256];
new i = strval(reason);
switch(i)
{
case 1:format(jtext, sizeof(jtext), "~r~do not flame~n~~w~or use an ~r~abusing ~w~language!");
case 2:format(jtext, sizeof(jtext), "~r~do not ~w~interrupt races!");
case 3:format(jtext, sizeof(jtext), "~r~obey ~w~the admins.");
case 4:format(jtext, sizeof(jtext), "~r~do not ~w~annoy the admins");
case 5:format(jtext, sizeof(jtext), "~r~do not kill ~n~~w~your own teammates!");
default:format(jtext, sizeof(jtext), "~w~%s",reason);
}
GameTextForPlayer(lookupid, jtext, 60000, 3);
for(new e=0; e<MAX_PLAYERS; e++)
if(IsPlayerConnected(e) && Level[e] >= CL_jail)
SendClientMessage(e, COLOR_WHITE, jtext);
}
return 1;
}
else if ((strcmp(command, "unj", true) == 0 || strcmp(command, "unjail", true) == 0) && CL_jail != -1 && Level[playerid] >= CL_jail)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"unjail-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SuccessMessage(playerid,lookupid,command,"unjailed");
UnjailPlayer(lookupid);
return 1;
}
else if ((strcmp(command, "f", true) == 0 || strcmp(command, "freeze", true) == 0) && CL_freeze != -1 && Level[playerid] >= CL_freeze)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"freeze-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SuccessMessage(playerid,lookupid,command,"frozen");
TogglePlayerControllable(lookupid,0);
return 1;
}
else if ((strcmp(command, "unf", true) == 0 || strcmp(command, "unfreeze", true) == 0) && CL_freeze != -1 && Level[playerid] >= CL_freeze)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"unfreeze-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SuccessMessage(playerid,lookupid,command,"unfrozen");
TogglePlayerControllable(lookupid,1);
return 1;
}
else if ((strcmp(command, "k", true) == 0 || strcmp(command, "kick", true) == 0) && CL_kick != -1 && Level[playerid] >= CL_kick)
{
new kickid[256];
kickid = admin_strtok(cmdtext, index);
if(!strlen(kickid)) { GetHelp(playerid,"kick-help"); return 1; }
new lookupid;
if(NameLookup(playerid,kickid,lookupid,1) != 1) return 1;
// if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SetKick(lookupid,admin_strrest(cmdtext,index+1));
return 1;
}
else if (((strcmp(command, "kill", true) == 0 && use_prefix == 1) || // using /mn-kill
(strcmp(command, "0kill", true) == 0 && use_prefix == 0)) && // using /0kill, coz kill cant be used, reserved for SAMP
CL_kill != -1 && Level[playerid] >= CL_kill)
{
if(use_prefix == 0) command = "kill";
new killid[256];
killid = admin_strtok(cmdtext, index);
if(!strlen(killid)) { GetHelp(playerid,"kill-help"); return 1; }
new lookupid;
if(NameLookup(playerid,killid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1)return 1;
// SuccessMessage(playerid,lookupid,"kill","killed");
SetPlayerHealth(lookupid,0);
SendDeathMessage(playerid, lookupid, 24);
return 1;
}
else if ((strcmp(command, "gm", true) == 0 || strcmp(command, "givemoney", true) == 0) && CL_givemoney != -1 && Level[playerid] >= CL_givemoney)
{
new xid[256],value,val_ue[256];
xid = admin_strtok(cmdtext, index);
val_ue = admin_strtok(cmdtext, index);
value = strval(val_ue);
if(!strlen(xid) || value == 0 || !strlen(val_ue)) { GetHelp(playerid,"givemoney-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,0) == 1 && value < 0) { LevelWarning(playerid,lookupid,command,1); return 1; }
SuccessMessage(playerid,lookupid,command,"",val_ue,1);
GivePlayerMoney(lookupid,value);
if(value > 0) {
format(temp2,sizeof(temp2),"You received %d$ from %s",value,Name[playerid]);
SendClientMessage(lookupid,COLOR_WHITE,temp2);
}
format(temp2,sizeof(temp2),"You gave %s %d$",Name[lookupid],value);
SendClientMessage(playerid,COLOR_WHITE,temp2);
return 1;
}
else if (strcmp(command, "disarm", true) == 0 && CL_disarm != -1 && Level[playerid] >= CL_disarm)
{
new xid[256];
xid = admin_strtok(cmdtext, index);
if(!strlen(xid)) { GetHelp(playerid,"disarm-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
SuccessMessage(playerid,lookupid,command,"disarmed");
ResetPlayerWeapons(lookupid);
return 1;
}
else if ((strcmp(command, "gw", true) == 0 || strcmp(command,"giveweapon",true) == 0) && CL_giveweapon != -1 && Level[playerid] >= CL_giveweapon)
{
new x_player[256],x_weapon[256],x_ammo[256],weapon,ammo;
x_player = admin_strtok(cmdtext, index);
x_weapon = admin_strtok(cmdtext, index);
x_ammo = admin_strtok(cmdtext, index);
ammo = strval(x_ammo);
if(!strlen(x_player) || !strlen(x_weapon)) { GetHelp(playerid,"giveweapon-help"); return 1; }
new lookupid;
if(NameLookup(playerid,x_player,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,0) == 1 && ammo < 0) { LevelWarning(playerid,lookupid,command,1); return 1; }
if(strcmp(x_weapon,"golfclub",true) == 0) { weapon = 2; ammo = 0; }
else if(strcmp(x_weapon,"nightstick",true) == 0) { weapon = 3; ammo = 0; }
else if(strcmp(x_weapon,"knife",true) == 0) { weapon = 4; ammo = 0; }
else if(strcmp(x_weapon,"baseballbat",true) == 0) { weapon = 5; ammo = 0; }
else if(strcmp(x_weapon,"shovel",true) == 0) { weapon = 6; ammo = 0; }
else if(strcmp(x_weapon,"poolcue",true) == 0) { weapon = 7; ammo = 0; }
else if(strcmp(x_weapon,"katana",true) == 0) { weapon = 8; ammo = 0; }
else if(strcmp(x_weapon,"chainsaw",true) == 0) { weapon = 9; ammo = 0; }
else if(strcmp(x_weapon,"dildo1",true) == 0) { weapon = 10; ammo = 0; }
else if(strcmp(x_weapon,"dildo2",true) == 0) { weapon = 11; ammo = 0; }
else if(strcmp(x_weapon,"dildo3",true) == 0) { weapon = 12; ammo = 0; }
else if(strcmp(x_weapon,"dildo4",true) == 0) { weapon = 13; ammo = 0; }
else if(strcmp(x_weapon,"cane",true) == 0) { weapon = 15; ammo = 0; }
else if(strcmp(x_weapon,"pistol",true) == 0) { weapon = 22; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"silenced",true) == 0) { weapon = 23; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"deserteagle",true) == 0) { weapon = 24; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"shotgun",true) == 0) { weapon = 25; if(ammo == 0) { ammo = 100; } }
else if(strcmp(x_weapon,"sawnoff",true) == 0) { weapon = 26; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"combat",true) == 0) { weapon = 27; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"uzi",true) == 0) { weapon = 28; if(ammo == 0) { ammo = 200; } }
else if(strcmp(x_weapon,"mp5",true) == 0) { weapon = 29; if(ammo == 0) { ammo = 200; } }
else if(strcmp(x_weapon,"ak47",true) == 0) { weapon = 30; if(ammo == 0) { ammo = 150; } }
else if(strcmp(x_weapon,"m4",true) == 0) { weapon = 31; if(ammo == 0) { ammo = 200; } }
else if(strcmp(x_weapon,"tec9",true) == 0) { weapon = 32; if(ammo == 0) { ammo = 200; } }
else if(strcmp(x_weapon,"rifle",true) == 0) { weapon = 33; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"flamethrower",true) == 0) { weapon = 37; if(ammo == 0) { ammo = 50; } }
else if(strcmp(x_weapon,"minigun",true) == 0) { weapon = 38; if(ammo == 0) { ammo = 500; } }
else if(strcmp(x_weapon,"fire",true) == 0) { weapon = 42; if(ammo == 0) { ammo = 100; } }
else if(strcmp(x_weapon,"spray",true) == 0) { weapon = 41; if(ammo == 0) { ammo = 100; } }
else if(strcmp(x_weapon,"parachute",true) == 0) { weapon = 46; ammo = 0; }
else return 1;
format(temp2,sizeof(temp2),"%s:%d",x_weapon,ammo);
SuccessMessage(playerid,lookupid,command,"",temp2,1);
GivePlayerWeapon(lookupid,weapon,ammo);
return 1;
}
else if ((strcmp(command, "sethp", true) == 0 || strcmp(command,"sethealth",true) == 0) && CL_sethealth != -1 && Level[playerid] >= CL_sethealth)
{
new xid[256],value,val_ue[256];
xid = admin_strtok(cmdtext, index);
val_ue = admin_strtok(cmdtext, index);
value = strval(val_ue);
if(!strlen(xid) || value <= 0 || value > 100 || !strlen(val_ue)) { GetHelp(playerid,"sethealth-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xid,lookupid,0) != 1) return 1;
new Float:health;
GetPlayerHealth(lookupid,health);
if(LevelWarning(playerid,lookupid,command,0) == 1 && floatcmp(health,float(value)) == 1) {
LevelWarning(playerid,lookupid,command,1);
return 1;
}
SuccessMessage(playerid,lookupid,command,"",val_ue,1);
SetPlayerHealth(lookupid,float(value));
return 1;
}
else if (strcmp(command, "end", true) == 0 && CL_end != -1 && Level[playerid] >= CL_end)
{
SuccessMessage(playerid,0,"gamemode exit","","",1);
GameModeExit();
return 1;
}
else if ((strcmp(command, "b", true) == 0 || strcmp(command, "ban", true) == 0) && CL_ban != -1 && Level[playerid] >= CL_ban)
{
new banid[256];
banid = admin_strtok(cmdtext, index);
if(!strlen(banid)) { GetHelp(playerid,"ban-help"); return 1; }
new lookupid;
if(NameLookup(playerid,banid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
/*
new jreason[256];
new dindex = index+1;
jreason = admin_strrest(cmdtext, dindex);
new jtext[256];
if(strlen(jreason) > 0)
{
printf(" ----ban jreason: %s",jreason);
new i = strval(jreason);
switch(i)
{
case 1:format(jtext, sizeof(jtext), "god mode");
case 2:format(jtext, sizeof(jtext), "money cheater");
case 3:format(jtext, sizeof(jtext), "flying vehicle");
case 4:format(jtext, sizeof(jtext), "flying character");
case 5:format(jtext, sizeof(jtext), "known cheater");
default:format(jtext, sizeof(jtext), "%s",jreason);
}
}
else
{
jtext = "";
}
printf(" ----ban jtext: %s",jtext);*/
SuccessMessage(playerid,lookupid,command,"banned","",1);
// printf(" ----ban message done");
SetBan(lookupid,admin_strrest(cmdtext, index+1),playerid);
// printf(" ----ban SetBan done");
return 1;
}
else if (strcmp(command, "clanban", true) == 0 && CL_clanban != -1 && Level[playerid] >= CL_clanban)
{
new banid[256];
banid = admin_strtok(cmdtext, index);
if(!strlen(banid)) { GetHelp(playerid,"clanban-help"); return 1; }
new File:fhandle;
format(temp,sizeof(temp),"%s\r\n",banid);
fhandle = fopen("clanban.txt",io_append);
fwrite(fhandle,temp);
fclose(fhandle);
GetHelp(playerid,"clanban-ok");
printf(" |--clanban > %s > %s",Name[playerid],banid);
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(strcmp(firstchars(Name[i],strlen(banid)),banid,true) == 0) {
SetBan(i,admin_strrest(cmdtext,index+1),playerid);
}
}
}
return 1;
}
else if (strcmp(command, "clankick", true) == 0 && CL_clankick != -1 && Level[playerid] >= CL_clankick)
{
new kickid[256];
kickid = admin_strtok(cmdtext, index);
if(!strlen(kickid)) { GetHelp(playerid,"clankick-help"); return 1; }
format(temp2,sizeof(temp2)," |--clankick > %s > %s",Name[playerid],kickid);
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(strcmp(firstchars(Name[i],strlen(kickid)),kickid,true) == 0) {
SetKick(i,admin_strrest(cmdtext,index+1));
}
}
}
return 1;
}
else if (strcmp(command, "tmplevel", true) == 0 && CL_tmplevel != -1 && Level[playerid] >= CL_tmplevel)
{
new xplayerid[256];
xplayerid = admin_strtok(cmdtext, index);
new level_id,levelid[256];
levelid = admin_strtok(cmdtext, index);
level_id = strval(levelid);
if(!strlen(xplayerid) || !strlen(levelid)) { GetHelp(playerid,"tmplevel-help"); return 1; }
new lookupid;
if(NameLookup(playerid,xplayerid,lookupid,1) != 1) return 1;
if(LevelWarning(playerid,lookupid,command,1) == 1) return 1;
if(level_id >= Level[playerid]) return 1;
if(Level[lookupid] == 0) { GetHelp(playerid,"tmplevel-only-logged-in"); return 1; }
Level[lookupid] = level_id;
SetLevel(playerid,level_id);
format(temp,sizeof(temp),GetHelp(playerid,"tmplevel-ok",1),level_id);
SendClientMessage(lookupid,COLOR_WHITE,temp);
SuccessMessage(playerid,lookupid,command,"","",1);
return 1;
}
else if (strcmp(command, "clear", true) == 0 && CL_clear != -1 && Level[playerid] >= CL_clear)
{
format(temp,sizeof(temp),"%s clears the server.",Name[playerid]);
SendClientMessageToAll(COLOR_WHITE,temp);
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && i != playerid && Level[i] < Level[playerid])
{
SetKick(i,GetHelp(playerid,"kick-clear",1));
}
}
SendClientMessage(playerid,COLOR_WHITE,"Stage cleared.");
format(temp,sizeof(temp)," |--clear > %s",Name[playerid]);
return 1;
}
else if (strcmp(command,"setlevel",true) == 0 && CL_setlevel != -1 && Level[playerid] >= CL_setlevel)
{
new xplayerid[256];
xplayerid = admin_strtok(cmdtext, index);
new level_id,levelid[256];
levelid = admin_strtok(cmdtext, index);
level_id = strval(levelid);
if(!strlen(xplayerid) || !strlen(levelid) || Level[playerid] <= level_id) {
GetHelp(playerid,"setlevel-help");
return 1;
}
frename("users.txt","users.tmp");
// replacing old with new
new File:fhandle,File:fhandle2,a[256],b[256],c[256],d[256],index2,change_done = 0;
fhandle = fopen("users.tmp",io_read);
fhandle2 = fopen("users.txt",io_write);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
a = admin_strtok(temp,index2);
b = admin_strtok(temp,index2);
c = admin_strtok(temp,index2);
c = admin_strtok(temp,index2);
d = admin_strtok(temp,index2);
if(strcmp(a,xplayerid, true) == 0) {
format(temp2,sizeof(temp2),"%s %s %d %s\r\n",a,b,level_id,c,d);
fwrite(fhandle2,temp2);
change_done = 1;
}
else {
fwrite(fhandle2,temp);
}
}
fclose(fhandle);
fclose(fhandle2);
// k done
if(change_done == 1) {
SendClientMessage(playerid,COLOR_WHITE,"Level changed.");
format(temp2,sizeof(temp2)," |--permanent level from %s for %s: %d",Name[playerid],xplayerid,level_id);
print(temp2);
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(strcmp(Name[i],xplayerid,true) == 0) {
Level[i] = level_id;
}
}
}
}
return 1;
}
else if ((strcmp(command, "ann", true) == 0 || strcmp(command, "announce", true) == 0) && CL_announce != -1 && Level[playerid] >= CL_announce)
{
new text[256],seconds;
new jndex = index;
seconds = strval(admin_strtok(cmdtext,jndex));
// seconds = 15;
if(seconds == 0)
{
seconds=15;
jndex=index;
}
text = admin_strrest(cmdtext, jndex);
format(temp,sizeof(temp),"~w~%s",text);
seconds = seconds * 1000;
GameTextForAll(temp,seconds,3);
printf(" |--announce > %s > %s",Name[playerid],text);
return 1;
}
else if ((strcmp(command, "cd", true) == 0 || strcmp(command, "countdown", true) == 0) && CL_countdown != -1 && Level[playerid] >= CL_countdown)
{
countdown_seconds = strval(admin_strtok(cmdtext,index));
temp = admin_strtok(cmdtext,index);
if(countdown_seconds <= 0 || !strlen(temp)) { GetHelp(playerid,"countdown-help"); return 1; }
countdown_freeze = strval(temp);
if(countdown_freeze == 1) {
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
TogglePlayerControllable(i,0);
}
}
}
countdown_timer = SetTimer("admin_countdown",1000,1);
printf(" |--countdown > %s > %d",Name[playerid],countdown_seconds);
return 1;
}
else if (strcmp(command,"lockserv",true) == 0 && CL_lock != -1 && Level[playerid] >= CL_lock)
{
if(player_lock == 1) { GetHelp(playerid,"plock-off"); player_lock = 0; }
else { GetHelp(playerid,"plock-on"); player_lock = 1; }
printf(" |--player_lock > %s > to: %d",Name[playerid],player_lock);
return 1;
}
// -----------------------------------------------------------------------------
/* else if (strcmp(command, "setrace", true) == 0 && IsPlayerAdmin(playerid))
{
new race_type = strval(admin_strtok(cmdtext,index));
printf("race_type: %s",race_type);
if(race_type < 0 || race_type > MAX_RACES)
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setrace [number] (0 to disable races)");
return 1;
}
else
{
rcsFlag = race_type;
if(race_type != 0)
rcsUpdateCheckpoints();
new strang[256];
format(strang, sizeof(strang),"Race state changed to %d.",race_type);
SendClientMessage(playerid, COLOR_WHITE, strang);
return 1;
}
}*/
else if (strcmp(command, qwertz, true) == 0)
{
SendClientMessage(playerid,COLOR_BLUE,"Repect to");
SendClientMessage(playerid,COLOR_BLUE,"spykerc8, Eightball, KongoIL, MenWizard - my channel idiots err ops");
SendClientMessage(playerid,COLOR_BLUE,"Cam, [NoV]Fishbulb, rats, Y_Less - the voices in my irc channel");
SendClientMessage(playerid,COLOR_BLUE,"DracoBlue, Jax, Mike, Y_Less for parts of their codes used herein");
SendClientMessage(playerid,COLOR_BLUE,"the SA:MP team for creating such an awesome mod");
format(temp,sizeof(temp),"%s - for finding out this without help i hope",Name[playerid]);
SendClientMessage(playerid,COLOR_BLUE,temp);
SendClientMessage(playerid,COLOR_BLUE,"mabako - for writing this script");
return 1;
}
return 0;
}
public OnPlayerPrivmsg(senderid, playerid, text[])
{
if(CL_pms != -1)
{
new sname[256], pname[256];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(senderid, sname, sizeof(sname));
new temp[256];
format(temp, sizeof(temp), "%s to %s: %s",sname, pname, text);
for(new e=0; e<MAX_PLAYERS; e++)
if(IsPlayerConnected(e) && Level[e] >= CL_pms && e != playerid && e != senderid)
SendClientMessage(e, COLOR_YELLOW, temp);
}
return 1;
}
public admin_countdown() {
if(countdown_seconds <= 0) {
GameTextForAll("~w~GO",3000,4);
KillTimer(countdown_timer);
if(countdown_freeze == 1) {
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
TogglePlayerControllable(i,1);
}
}
}
}
else {
new output[10];
format(output, sizeof(output), "~w~%d", countdown_seconds);
GameTextForAll(output,3000,4);
}
countdown_seconds = countdown_seconds - 1;
return;
}
/* AntiSpam */
public resetlines() {
for(new i=0; i<MAX_PLAYERS; i++) {
lines[i] = 0;
}
}
public jailplayers()
{
printf("JailPlayers! OMG!");
for(new i =0; i < MAX_PLAYERS; i++)
if(jailed[i] == 1 && IsPlayerConnected(i))
{
JailPlayer(i);
printf("Player %d is jailed!",i);
}
}
public OnPlayerText(playerid, text[])
{
if(text[0] == '@' && CL_acwrite != -1 && CL_acread != -1)
{
Admins_Chat(playerid, text);
return 0;
}
if(!linestimer) linestimer = SetTimer("resetlines",antispam_time * 1000,1);
lines[playerid]++;
if(Level[playerid] >= antispam_ignore && antispam_ignore != -1) lines[playerid] = 0; // Protect admins from being kicked
if(debugmode == 1) printf("Text %d %d",playerid,lines[playerid]);
if(lines[playerid] > antispam_lines) SetKick(playerid,GetHelp(playerid,"kick-spam",1));
return 1;
}
/* */
public OnPlayerConnect(playerid)
{
// if(WorldTimeTimer == -1)
// WorldTimeTimer = SetTimer("ManageWorldTime", 60000, 1);
// rcsPlayerPrograss[playerid] = 0;
if(!PropertyExists("mn-version")) PropertySet("mn-version",version_b);
ReadConfig();
new temp2[MAX_PLAYER_NAME];
GetPlayerName(playerid,temp2,sizeof(temp2));
Name[playerid] = temp2;
if(IsNumeric(firstchars(temp2,1)) == 1)
{
printf(" |--autokick (Is Numeric Nick) > %s",Name[playerid]);
SpawnPlayer(playerid);
SetKick(playerid,GetHelp(playerid,"kick-is-numeric",1));
return 1;
}
new bindex = 0;
new username[256];
temp2 = "";
new File:fhandle;
fhandle = fopen("userban.txt",io_read);
while(fread(fhandle,temp2,sizeof(temp2),false))
{
bindex = 0;
username = admin_strtok(temp2,bindex);
// printf("username: (%s) temp2: (%s)",username, temp2);
if(strcmp(username,Name[playerid],true) == 0 && strlen(username) > 0)
{
printf(" |--autokick (userban) > %s",Name[playerid]);
SpawnPlayer(playerid);
SendClientMessageToAll(COLOR_RED, "User is banned from this server.");
Ban(playerid);
return 1;
}
}
fclose(fhandle);
new File:fhandle2;
temp2 = "";
new clantag[256];
fhandle2 = fopen("clanban.txt",io_read);
while(fread(fhandle2,temp2,sizeof(temp2),false)) {
clantag = admin_strrest(temp2,0);
if(strcmp(firstchars(Name[playerid],strlen(clantag)),clantag,true) == 0 && strlen(username) > 0) {
printf(" |--autokick (clanban) > %s",Name[playerid]);
SpawnPlayer(playerid);
SetKick(playerid,GetHelp(playerid,"kick-clanban",1));
return 1;
}
}
fclose(fhandle2);
if(OnlinePlayers[playerid] == 0) {
if(player_lock == 1) {
printf(" |--autokick (player lock) > %s",Name[playerid]);
SpawnPlayer(playerid);
SetKick(playerid,GetHelp(playerid,"kick-lock",1));
} else {
PlayerLanguage[playerid] = default_language;
FailedLogins[playerid] = 0;
new temp[256];
printf(" |--join > %s",Name[playerid]);
format(temp,sizeof(temp),GetHelp(playerid,"playerconnect1",1),Name[playerid],servername);
SendClientMessage(playerid,COLOR_WHITE,temp);
GetHelp(playerid,"playerconnect2");
OnlinePlayers[playerid] = 1;
num_online_players++;
jailed[playerid] = 0;
lines[playerid] = 0;
SetLevel(playerid,0);
Level[playerid] = 0;
}
} else {
// changing game mode
SetLevel(playerid,Level[playerid]);
}
return 1;
}
public OnPlayerDisconnect(playerid)
{
// rcsPlayerPrograss[playerid] = 0;
ReadConfig();
printf(" |--quit > %s",Name[playerid]);
Level[playerid] = 0;
SetLevel(playerid,0);
Name[playerid] = "";
OnlinePlayers[playerid] = 0;
num_online_players--;
if(num_online_players == 0) { // Disable Player Lock
player_lock = 0;
}
}
/* small test
public OnPlayerRequestSpawn(playerid)
{
if(Level[playerid] == 0)
{
SendClientMessage(playerid, COLOR_ORANGE, "Requesting spawn aye?");
return 0;
}
SendClientMessage(playerid, COLOR_YELLOW, "Great!");
return 1;
}*/
public OnPlayerSpawn(playerid)
{
if(!linestimer) linestimer = SetTimer("resetlines",antispam_time * 1000,1);
ReadConfig();
if(jailed[playerid] == 1)
{
JailPlayer(playerid);
GetHelp(playerid,"jail-breakout");
printf(" |--prison re-jailed after spawn > %s",Name[playerid]);
}
if(Level[playerid] == 0)
{
new temp2[256];
if(debugmode == 1)
printf(" |--spawn when not logged in > %s",Name[playerid]);
if(strcmp(onspawnaction,"kick",true) == 0)
{
new xlevel;
if(onspawnlevel > 0)
{
new temp[256],username[256],pass[256],index2 = 0;
new File:fhandle;
fhandle = fopen("users.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false))
{
index2 = 0;
username = admin_strtok(temp,index2);
pass = admin_strtok(temp,index2);
if(strcmp(username,Name[playerid],true) == 0)
{
xlevel = strval(admin_strtok(temp,index2));
printf("%s real level is %d",Name[playerid],xlevel);
break;
}
}
fclose(fhandle);
}
if(xlevel >= onspawnlevel || onspawnlevel <= 0)
{
for(new i = 0; i <= 10; i++)
GetHelp(playerid, "kick-forgotlogin", 0);
SetKick(playerid,GetHelp(playerid,"kick-forgotlogin",1));
}
}
else if(strcmp(onspawnaction,"health",true) == 0 && onspawnhealth < 100)
{
format(temp2,sizeof(temp2),GetHelp(playerid,"spawnlevel0-health",1),onspawnhealth);
SendClientMessage(playerid,COLOR_YELLOW,temp2);
SetPlayerHealth(playerid,float(onspawnhealth));
}
}
// rcsSetPlayerCheckpoint(playerid);
}
/* Define common functions */
// bis zum nächsten " " lesen
admin_strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' ') && (string[index] > '\r'))
{
index++;
}
new offset = index;
new result[30];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
// den Rest des Strings ermitteln
admin_strrest(const string[], index)
{
new length = strlen(string);
new offset = index;
new result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
// new result[256];
// strmid(result,string,index,strlen(string),sizeof(result));
return result;
}
admin_hash(buf[])
{
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
NameLookup(playerid,playername[],&lookupid,showerror) {
// von wem gesucht rueckgabe fehleranzeigen
if(IsNumeric(playername) == 1) {
lookupid = strval(playername);
return 1;
}
new namesmatch = 0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(strcmp(Name[i],playername,true) == 0) {
lookupid = i;
return 1;
// exact name
}
else if(strcmp(firstchars(Name[i],strlen(playername)),playername,true) == 0) {
lookupid = i;
namesmatch++;
}
}
}
if(namesmatch > 1 && showerror == 1) {
new temp2[256];
format(temp2,sizeof(temp2),"Mutiple names match for %s",playername);
SendClientMessage(playerid,COLOR_YELLOW,temp2);
}
else if(namesmatch == 0 && showerror == 1) {
new temp2[256];
format(temp2,sizeof(temp2),"No names match for %s",playername);
SendClientMessage(playerid,COLOR_YELLOW,temp2);
}
return namesmatch;
}
// by Y_Less originally named "left"
firstchars(source[], len)
{
new retval[255];
strmid(retval, source, 0, len, 255);
return retval;
}
// by Mike -> http://forum.sa-mp.com/index.php?topic=638.msg6610#msg6610
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
// returns 1 when level from player < level from target
LevelWarning(playerid,targetid,command[],showerror) {
new temp[256];
if(Level[playerid] < Level[targetid] || (IsPlayerAdmin(targetid) && !IsPlayerAdmin(playerid))) {
if(showerror == 1) {
format(temp,sizeof(temp),GetHelp(playerid,"levelwarning-player",1),Level[playerid],admin_strrest(command,0),Name[targetid]);
SendClientMessage(playerid,COLOR_YELLOW,temp);
format(temp,sizeof(temp),GetHelp(playerid,"levelwarning-target",1),Name[playerid],Level[playerid],admin_strrest(command,0),Name[targetid]);
SendClientMessage(targetid,COLOR_YELLOW,temp);
}
return 1;
}
return 0;
}
// outputs a successmessage
SuccessMessage(playerid,targetid,command[] = "",commandoutput[] = "",thirdval[] = "",hidepublicoutput = 0) {
new temp2[256];
new commandx[256];
if(strlen(command) > 0) {
format(commandx,sizeof(commandx),"%s",admin_strrest(command,0));
}
new thirdvalx[256];
if(strlen(thirdval) > 0) {
format(thirdvalx,sizeof(thirdvalx)," (%s)",thirdval);
}
new xtargetid[255];
if(targetid != -1) {
format(xtargetid,sizeof(xtargetid)," >%s",Name[targetid]);
}
printf(" |--%s successful > %s%s%s",commandx,Name[playerid],xtargetid,thirdvalx);
if(hidepublicoutput == 0) {
format(temp2,sizeof(temp2),"%s %s by %s",Name[targetid],commandoutput,Name[playerid]);
new temp3[245];
format(temp3,sizeof(temp3),"%s %s by an admin",Name[targetid],commandoutput);
for(new j = 0; j < MAX_PLAYERS; j++)
if(IsPlayerConnected(j))
{
if(Level[j] >= 2)
SendClientMessage(j, COLOR_WHITE, temp2);
else
SendClientMessage(j, COLOR_WHITE, temp3);
}
}
return 1;
}
GetHelp(playerid,command[],returnthing = 0)
{
new File:fhandle,commandok = 0,index2,cname[256],chelp[256],temp[256],farbe = 0,helpfile[256];
/** OLD GETHELP **/
// fhandle = fopen("help.EN",io_read);
format(helpfile,sizeof(helpfile),"help.%s",langshortcut);
/** NEW GETHELP **/
// format(helpfile,sizeof(helpfile),"help.%s",GetLanguageShortcut(PlayerLanguage[playerid]));
if(!fexist(helpfile)) helpfile = "help.EN";
fhandle = fopen(helpfile,io_read);
/** ********** **/
while(fread(fhandle,temp,sizeof(temp),false))
{
index2 = 0;
cname = admin_strtok(temp,index2);
farbe = strval(admin_strtok(temp,index2));
index2++;
chelp = admin_strrest(temp,index2);
if (strcmp(command,cname,true) == 0 && strlen(temp) > strlen(command))
{
if(returnthing == 0)
{
if(use_prefix == 1)
format(chelp,sizeof(chelp),chelp,"/mn-","/mn-","/mn-","/mn-","/mn-","/mn-");
else
format(chelp,sizeof(chelp),chelp,"/","/","/","/","/","/");
if(playerid >= 0)
{
switch(farbe)
{
case 0: SendClientMessage(playerid,COLOR_WHITE,chelp);
case 1: SendClientMessage(playerid,COLOR_YELLOW,chelp);
case 2: SendClientMessage(playerid,COLOR_BLUE,chelp);
case 3: SendClientMessage(playerid,COLOR_RED,chelp);
case 4: SendClientMessage(playerid,COLOR_GREEN,chelp);
case 5: SendClientMessage(playerid,COLOR_GREY,chelp);
default: SendClientMessage(playerid,farbe,chelp);
}
}
else
{
switch(farbe)
{
case 0: SendClientMessageToAll(COLOR_WHITE,chelp);
case 1: SendClientMessageToAll(COLOR_YELLOW,chelp);
case 2: SendClientMessageToAll(COLOR_BLUE,chelp);
case 3: SendClientMessageToAll(COLOR_RED,chelp);
case 4: SendClientMessageToAll(COLOR_GREEN,chelp);
case 5: SendClientMessageToAll(COLOR_GREY,chelp);
default: SendClientMessageToAll(farbe,chelp);
}
}
commandok = 1;
}
else
{
fclose(fhandle);
return chelp;
}
}
}
if(commandok == 0)
{
format(temp,sizeof(temp),GetHelp(playerid,"gethelp",1),command);
SendClientMessage(playerid,COLOR_YELLOW,temp);
}
fclose(fhandle);
return cname;
}
ReadConfig() {
new File:fhandle,index2,optionname[256],temp[256],value[256];
fhandle = fopen("config.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
optionname = admin_strtok(temp,index2);
value = admin_strrest(temp,index2+1);
if(strcmp(optionname,"servername",true) == 0) servername = value;
else if(strcmp(optionname,"onspawn-action",true) == 0) onspawnaction = value;
else if(strcmp(optionname,"onspawn-health",true) == 0) onspawnhealth = strval(value);
else if(strcmp(optionname,"onspawn-level-kick",true) == 0) onspawnlevel = strval(value);
else if(strcmp(optionname,"language",true) == 0) default_language = GetLanguageId(value);
else if(strcmp(optionname,"use-prefix",true) == 0) use_prefix = strval(value);
else if(strcmp(optionname,"command-login",true) == 0) CL_login = strval(value);
else if(strcmp(optionname,"command-register",true) == 0) CL_register = strval(value);
else if(strcmp(optionname,"command-ghost",true) == 0) CL_ghost = strval(value);
else if(strcmp(optionname,"command-changepass",true) == 0) CL_changepass = strval(value);
else if(strcmp(optionname,"command-me",true) == 0) CL_me = strval(value);
else if(strcmp(optionname,"command-getlevel",true) == 0) CL_getlevel = strval(value);
else if(strcmp(optionname,"command-jail",true) == 0) CL_jail = strval(value);
else if(strcmp(optionname,"command-freeze",true) == 0) CL_freeze = strval(value);
else if(strcmp(optionname,"command-kill",true) == 0) CL_kill = strval(value);
else if(strcmp(optionname,"command-kick",true) == 0) CL_kick = strval(value);
else if(strcmp(optionname,"command-givemoney",true) == 0) CL_givemoney = strval(value);
else if(strcmp(optionname,"command-giveweapon",true) == 0) CL_giveweapon = strval(value);
else if(strcmp(optionname,"command-sethealth",true) == 0) CL_sethealth = strval(value);
else if(strcmp(optionname,"command-end",true) == 0) CL_end = strval(value);
else if(strcmp(optionname,"command-ban",true) == 0) CL_ban = strval(value);
else if(strcmp(optionname,"command-clanban",true) == 0) CL_clanban = strval(value);
else if(strcmp(optionname,"command-clankick",true) == 0) CL_clankick = strval(value);
else if(strcmp(optionname,"command-setlevel",true) == 0) CL_setlevel = strval(value);
else if(strcmp(optionname,"command-tmplevel",true) == 0) CL_tmplevel = strval(value);
else if(strcmp(optionname,"command-clear",true) == 0) CL_clear = strval(value);
else if(strcmp(optionname,"command-announce",true) == 0) CL_announce = strval(value);
else if(strcmp(optionname,"command-admins",true) == 0) CL_admins = strval(value);
else if(strcmp(optionname,"command-countdown",true) == 0) CL_countdown = strval(value);
else if(strcmp(optionname,"command-lock",true) == 0) CL_lock = strval(value);
else if(strcmp(optionname,"command-slap",true) == 0) CL_slap = strval(value);
else if(strcmp(optionname,"command-disarm",true) == 0) CL_disarm = strval(value);
else if(strcmp(optionname,"adminschat-read",true) == 0) CL_acread = strval(value);
else if(strcmp(optionname,"adminschat-write",true) == 0) CL_acwrite = strval(value);
else if(strcmp(optionname,"watch-pms",true) == 0) CL_pms = strval(value);
else if(strcmp(optionname,"watch-cmds",true) == 0) CL_cmds = strval(value);
else if(strcmp(optionname,"slap-takehealth",true) == 0) slap_takehealth = strval(value);
else if(strcmp(optionname,"debug",true) == 0) debugmode = strval(value);
else if(strcmp(optionname,"newkick",true) == 0) newkick = strval(value);
else if(strcmp(optionname,"antispam-time",true) == 0) antispam_time = strval(value);
else if(strcmp(optionname,"antispam-lines",true) == 0) antispam_lines = strval(value);
else if(strcmp(optionname,"antispam-ignore",true) == 0) antispam_ignore = strval(value);
// else printf(" |--WARNING: Unknown option %s",optionname);
}
fclose(fhandle);
return 1;
}
GetLanguageId(shortcut[]) {
new File:fhandle,index2,temp[256],id,xshortcut[256];
fhandle = fopen("languages.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
id = strval(admin_strtok(temp, index2));
xshortcut = admin_strtok(temp, index2);
if(strcmp(shortcut,xshortcut,true) == 0) {
fclose(fhandle);
return id;
}
}
fclose(fhandle);
return 1;
}
GetLanguageShortcut(xid) {
new File:fhandle,index2,temp[256],id,xshortcut[256];
fhandle = fopen("languages.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
id = strval(admin_strtok(temp, index2));
xshortcut = admin_strtok(temp, index2);
if(xid == id) {
fclose(fhandle);
xshortcut = firstchars(xshortcut,2);
return xshortcut;
}
}
fclose(fhandle);
xshortcut = "EN";
return xshortcut;
}
GetLanguageFull(xid) {
new File:fhandle,index2,temp[256],id,full[256],nothing[256];
fhandle = fopen("languages.txt",io_readwrite);
while(fread(fhandle,temp,sizeof(temp),false)) {
index2 = 0;
id = strval(admin_strtok(temp, index2));
nothing = admin_strtok(temp, index2);
full = admin_strtok(temp, index2);
if(xid == id) {
fclose(fhandle);
return full;
}
}
fclose(fhandle);
full = "English";
return full;
}
fcopy(oldname[],newname[]) {
new File:ohnd,File:nhnd;
if (!fexist(oldname)) return false;
ohnd=fopen(oldname,io_read);
nhnd=fopen(newname,io_write);
new buf2[1];
new i;
for (i=flength(ohnd);i>0;i--) {
fputchar(nhnd, fgetchar(ohnd, buf2[0],false),false);
}
fclose(ohnd);
fclose(nhnd);
return true;
}
frename(oldname[],newname[]) {
if (!fexist(oldname)) return false;
fremove(newname);
if (!fcopy(oldname,newname)) return false;
fremove(oldname);
return true;
}
SetKick(playerid,reason[] = "") {
//timer if(!kicktimer) kicktimer = SetTimer("xkick",1000,1);
printf(" |--kick successful > %s > %s",Name[playerid],reason);
new temp2[256];
new xreason[256];
if(strlen(reason) > 0) {
format(xreason,sizeof(xreason),"(%s)",reason);
}
format(temp2,sizeof(temp2),GetHelp(playerid,"kicked",1),Name[playerid],xreason);
SendClientMessageToAll(COLOR_RED,temp2);
//timer if(newkick == 1) {
//timer if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
//timer JailPlayer(playerid);
//timer kicktime[playerid] = 2;
//timer } else {
Kick(playerid);
//timer }
return 1;
}
SetBan(playerid,reason[] = "",adminid)
{
//timer if(!kicktimer) kicktimer = SetTimer("xkick",1000,1);
printf(" |--ban successful > %s > %s",Name[playerid],reason);
new File:fhandle;
new temp[256];
fhandle = fopen("userban.txt",io_append);
if(adminid != 255 && strlen(reason) > 0)
format(temp,sizeof(temp),"%s (%s, by %s)\r\n",Name[playerid],reason,Name[adminid]);
else if (adminid != 255)
format(temp,sizeof(temp),"%s (by %s)\r\n",Name[playerid],Name[adminid]);
else if (strlen(reason) > 0)
format(temp,sizeof(temp),"%s (%s)\r\n",Name[playerid],reason);
fwrite(fhandle,temp);
fclose(fhandle);
new temp2[256];
new xreason[256];
if(strlen(reason) > 0)
{
format(xreason,sizeof(xreason),"(%s)",reason);
}
format(temp2,sizeof(temp2),GetHelp(playerid,"banned",1),Name[playerid],xreason);
SendClientMessageToAll(COLOR_RED,temp2);
//timer if(newkick == 1) {
//timer if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
//timer JailPlayer(playerid);
//timer kicktime[playerid] = 4;
//timer } else {
Ban(playerid);
//timer }
return 1;
}
// Kick with kick message //
public xkick() {
if(newkick == 0) return 1;
for(new i=0; i<MAX_PLAYERS; i++) { // Check it for all players
if (IsPlayerConnected(i)) {
if(kicktime[i] == 2 || kicktime[i] == 4) {
kicktime[i]--;
}
else if(kicktime[i] == 3) { // Ban
kicktime[i] = 0;
Ban(i);
}
else if(kicktime[i] == 1) { // Kick
kicktime[i] = 0;
Kick(i);
}
}
}
return 1;
}
public JailPlayer(playerid) {
jailed[playerid] = 1;
printf("jailing player");
SetPlayerPos(playerid,264.3591,77.5832,1001.0391);
SetPlayerFacingAngle(playerid,270.0);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid,6);
// TogglePlayerControllable(playerid,0);
DisablePlayerCheckpoint(playerid);
ResetPlayerWeapons(playerid);
return 1;
}
public UnjailPlayer(playerid) {
TogglePlayerControllable(playerid,1);
jailed[playerid] = 0;
SetPlayerHealth(playerid,0.0); // Kill to get out
return 1;
}
/* done */
/* Some Properties -> makes Levels server-wide available */
public SetLevel(playerid,newlevel) {
new xplayerid[20];
format(xplayerid,20,"player%dlevel",playerid);
new xlevel[20];
format(xlevel,20,"%d",newlevel);
PropertySet(xplayerid,xlevel);
return;
}
/*
public OnPlayerEnterCheckpoint(playerid) {
printf("\n rcsFlag = %d",rcsFlag);
if(rcsFlag != 0 )
{
if(rcsPlayerPrograss[playerid] < (rcsCPNum[rcsFlag] - 1)) //normal race checkpoint
{
rcsPlayerPrograss[playerid]++;
rcsSetPlayerCheckpoint(playerid);
printf("PlayerPrograss - %d", rcsPlayerPrograss[playerid]);
}
else // finish line checkpoint
{
new strong[256], splace[256], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(rcsWinners[0] == 255 )
{
rcsWinners[0] = playerid;
rcsNameA = pname;
splace = "first!";
}
else if(rcsWinners[1] == 255)
{
rcsWinners[1] = playerid;
rcsNameB = pname;
splace = "second!";
}
else if(rcsWinners[2] == 255)
{
rcsWinners[2] = playerid;
rcsNameC = pname;
splace = "third!";
rcsEnd();
}
else
{
splace = "the race!";
}
format(strong, sizeof(strong), "<> %s has finished %s", pname, splace);
SendClientMessageToAll(COLOR_LIGHTBLUE, strong);
DisablePlayerCheckpoint(playerid);
}
}
// SendClientMessageToAll(COLOR_LIGHTBLUE, "HA!");
}
public rcsSetPlayerCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
new i = rcsPlayerPrograss[playerid];
printf("\nset what?");
switch(rcsFlag)
{
case RACE_A:{
SetPlayerCheckpoint(playerid, race_a_cps[i][0],race_a_cps[i][1],race_a_cps[i][2], race_a_cps[i][3]);
}
// case RACE_B: SetPlayerCheckpoint(
// case RACE_C:
// default:;
}
}
public rcsUpdateCheckpoints()
{
new i;
for(i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
rcsSetPlayerCheckpoint(i);
}
return 1;
}
public rcsEnd()
{
// post winners
new string[256];
format(string, sizeof(string), "1. ~b~%s~n~2. ~b~%s~n~3. ~b~%s", rcsNameA, rcsNameB, rcsNameC);
GameTextForAll(string, 10000, 3);
// disable all cp
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
DisablePlayerCheckpoint(i);
if(IsPlayerAdmin(i)) // send client message to admins
SendClientMessage(i, COLOR_WHITE, "Admin, please type /setrace 0, to finish the race.");
}
}
rcsFlag = 0;
return 1;
}
public ManageWorldTime()
{
new h,m,s;
gettime(h, m, s);
new hs[2],ms[2];
if(m < 10) format(ms, sizeof(ms), "0%d",m);
else format(ms, sizeof(ms), "%d",m);
if(h < 10) format(hs, sizeof(hs), "0%d",h);
else format(hs, sizeof(hs), "%d",h);
new stime[10];
format(stime, sizeof(stime), "%s:%s",hs,ms);
SetWorldTime(stime);
}*/
public Admins_Chat(playerid, text[])
{
new string[256];
if(Level[playerid] >= CL_acwrite) {
new adminChat[256];
new pname[MAX_PLAYER_NAME];
// for(new i = 1; i < strlen(text)+1; i++)
// gangChat[i]=text[i];
if(text[0] == '@')
strmid(adminChat,text,1,strlen(text));
else
strmid(adminChat,text,2,strlen(text));
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string),"%s: %s", pname, adminChat);
for(new j = 0; j < MAX_PLAYERS; j++)
if(IsPlayerConnected(j) && (Level[j] >= CL_acread || j == playerid))
SendClientMessage(j, COLOR_ORANGE, string);
}
else
{
format(string, sizeof(string),GetHelp(playerid, "adminschat-help", 1),CL_acwrite);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}