//——————-This is a quick Cops ‘n’ Robbers Gamemode by Billy done as an ‘assignment’ for Mr.Alex to demonstrate his scripting capabilities——————-//
//Created: February 8th
//Last editted: February 10th
//Includes
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <a_mysql>
#include <foreach>
#include <timerfix>
//MySQL connect information
#define mysql_host “127.0.0.1”
#define mysql_user “root”
#define mysql_password “”
#define mysql_database “aCnR”
//Colours
#define COLOR_GRAY 0xAFAFAFAA
#define COLOR_RED 0xFF0000AA
#define COLOR_GREEN 0x33FF33AA
#define COLOR_BLUE 0x2894FFFF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_SWAT 0x60C8EBAA
//Commonly used messages
#define SendUsage(%0,%1); SendClientMessage(%0,COLOR_GRAY,%1);
#define SendNotAuthorized(%0); SendClientMessage(%0,COLOR_RED,”ERROR: You are not authorized to use this command.”);
#define SendInvalidPlayer(%0); SendClientMessage(%0,COLOR_RED,”ERROR: The player you have specified it not connected/invalid.”);
//Global vars
new SQLConnection;
new LottoOnGoing;
new LottoPrize;
new RapeDamageTime[MAX_PLAYERS];
new PatriotCount;
new TotalVehicles;
new ShootTimer[MAX_PLAYERS];
new ShootTimerActive[MAX_PLAYERS];
//Gates
new Police_Gate;
new SWAT_Gate1;
new SWAT_Gate2;
new PoliceGateCheck;
new PoliceGateTimer;
new SwatGate1Check;
new SwatGate1Timer;
new SwatGate2Check;
new SwatGate2Timer;
//Dialog IDs
#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1
#define DIALOG_MENU 2
#define DIALOG_TELEPORTS 3
//Whirlpool encryption
native WP_Hash(buffer[], len, const str[]);
//Forwards
forward Kicked(playerid);
forward FiveMinutes();
forward LottoDraw();
forward PoliceGate();
forward SwatGate1();
forward SwatGate2();
forward RobTimer(playerid);
forward RapeTimer(playerid);
forward RapeDamageTimer(playerid);
forward SamRecTimer(playerid);
forward PatriotShootTimer(playerid);
forward UnJail(playerid);
//Player vars
enum pInfo
{
SQLID,
Name[MAX_PLAYER_NAME],
AdminLevel,
IP[16],
LoggedIn,
Spawned,
V,
Team,
SWAT,
LottoNum,
Money,
Cuffed,
Arrested,
RecentlyRobbed,
RecentlyRaped,
SamRec,
Firing
};
new PlayerInfo[MAX_PLAYERS][pInfo];
//Custom patriots
#define MAX_PATRIOTS 3
enum cpInfo
{
vehid,
ptype,
object,
object2,
gunflash1,
gunflash2
}
new PatriotInfo[MAX_PATRIOTS][cpInfo];
//Patriot variables
#define PATRIOT_MAX_SHOOT_DISTANCE 10.0
#define PATRIOT_MINIGUN_PLAYER_DAMAGE 10.0
#define PATRIOT_MINIGUN_VEHICLE_DAMAGE 50.0
#define PATRIOT_M4_PLAYER_DAMAGE 2.0
#define PATRIOT_M4_VEHICLE_DAMAGE 10.0
//Key released
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
//Spawn coords
new Float:CivilianSpawns[3][3] =
{
{1159.1378,-1272.7616,13.5469},
{1204.4657,-1414.2145,13.3577},
{1353.0378,-1742.0817,13.5469}
};
new Float:CopSpawns[2][3] =
{
{1585.7330,-1687.0334,6.2188},
{1568.3926,-1696.1250,5.8906}
};
new Float:SWATSpawns[3][3] =
{
{747.0264,-1349.5563,13.5073},
{760.7242,-1359.4187,13.5196},
{765.8098,-1335.4860,13.5382}
};
//Vehicle names for /v & GetVehicleModelFromName
new VehicleNames[212][] =
{
“Landstalker”,”Bravura”,”Buffalo”,”Linerunner”,”Pereniel”,”Sentinel”,”Dumper”,”Firetruck”,”Trashmaster”,”Stretch”,”Manana”,”Infernus”,
“Voodoo”,”Pony”,”Mule”,”Cheetah”,”Ambulance”,”Leviathan”,”Moonbeam”,”Esperanto”,”Taxi”,”Washington”,”Bobcat”,”Mr Whoopee”,”BF Injection”,
“Hunter”,”Premier”,”Enforcer”,”Securicar”,”Banshee”,”Predator”,”Bus”,”Rhino”,”Barracks”,”Hotknife”,”Trailer”,”Previon”,”Coach”,”Cabbie”,
“Stallion”,”Rumpo”,”RC Bandit”,”Romero”,”Packer”,”Monster”,”Admiral”,”Squalo”,”Seasparrow”,”Pizzaboy”,”Tram”,”Trailer”,”Turismo”,”Speeder”,
“Reefer”,”Tropic”,”Flatbed”,”Yankee”,”Caddy”,”Solair”,”Berkley’s RC Van”,”Skimmer”,”PCJ-600″,”Faggio”,”Freeway”,”RC Baron”,”RC Raider”,
“Glendale”,”Oceanic”,”Sanchez”,”Sparrow”,”Patriot”,”Quad”,”Coastguard”,”Dinghy”,”Hermes”,”Sabre”,”Rustler”,”ZR3 50″,”Walton”,”Regina”,
“Comet”,”BMX”,”Burrito”,”Camper”,”Marquis”,”Baggage”,”Dozer”,”Maverick”,”News Chopper”,”Rancher”,”FBI Rancher”,”Virgo”,”Greenwood”,
“Jetmax”,”Hotring”,”Sandking”,”Blista Compact”,”Police Maverick”,”Boxville”,”Benson”,”Mesa”,”RC Goblin”,”Hotring Racer A”,”Hotring Racer B”,
“Bloodring Banger”,”Rancher”,”Super GT”,”Elegant”,”Journey”,”Bike”,”Mountain Bike”,”Beagle”,”Cropdust”,”Stunt”,”Tanker”,”RoadTrain”,
“Nebula”,”Majestic”,”Buccaneer”,”Shamal”,”Hydra”,”FCR-900″,”NRG-500″,”HPV1000″,”Cement Truck”,”Tow Truck”,”Fortune”,”Cadrona”,”FBI Truck”,
“Willard”,”Forklift”,”Tractor”,”Combine”,”Feltzer”,”Remington”,”Slamvan”,”Blade”,”Freight”,”Streak”,”Vortex”,”Vincent”,”Bullet”,”Clover”,
“Sadler”,”Firetruck”,”Hustler”,”Intruder”,”Primo”,”Cargobob”,”Tampa”,”Sunrise”,”Merit”,”Utility”,”Nevada”,”Yosemite”,”Windsor”,”Monster A”,
“Monster B”,”Uranus”,”Jester”,”Sultan”,”Stratum”,”Elegy”,”Raindance”,”RC Tiger”,”Flash”,”Tahoma”,”Savanna”,”Bandito”,”Freight”,”Trailer”,
“Kart”,”Mower”,”Duneride”,”Sweeper”,”Broadway”,”Tornado”,”AT-400″,”DFT-30″,”Huntley”,”Stafford”,”BF-400″,”Newsvan”,”Tug”,”Trailer A”,”Emperor”,
“Wayfarer”,”Euros”,”Hotdog”,”Club”,”Trailer B”,”Trailer C”,”Andromada”,”Dodo”,”RC Cam”,”Launch”,”Police Car (LSPD)”,”Police Car (SFPD)”,
“Police Car (LVPD)”,”Police Ranger”,”Picador”,”S.W.A.T. Van”,”Alpha”,”Phoenix”,”Glendale”,”Sadler”,”Luggage Trailer A”,”Luggage Trailer B”,
“Stair Trailer”,”Boxville”,”Farm Plow”,”Utility Trailer”
};
new Aircraft[12] =
{
460,
476,
497,
511,
512,
513,
519,
520,
553,
577,
592,
593
};
main() { }
public OnGameModeInit()
{
//Initial gamemode stuff
print(“\n———————————-“);
print(“—-Cops ‘n’ Robbers by Billy—-“);
print(“———————————-\n”);
print(“Loading the Cops ‘n’ Robbers gamemode”);
SetGameModeText(“Cops ‘n’ Robbers”);
SendRconCommand(“weburl www.code5gaming.com”);
SendRconCommand(“hostname Billy’s Basic CnR”);
SendRconCommand(“mapname Los Santos”);
SendRconCommand(“language English”);
SetTimer(“FiveMinutes”,300000,true);
PatriotCount = -1;
//Random SAMP patches
UsePlayerPedAnims();
DisableInteriorEnterExits();
AllowInteriorWeapons(1);
//Gates
Police_Gate = CreateObject(971, 1588.66699, -1637.86975, 14.97660, 0.00000, 0.00000, 0.00000);
SWAT_Gate1 = CreateObject(975, 778.15979, -1384.83679, 14.23520, 0.00000, 0.00000, 0.00000); //Down pos = take 5 off
SWAT_Gate2 = CreateObject(975, 777.87622, -1330.33008, 14.02322, 1.44000, -0.18000, -1.14000);
//SQL Connection
mysql_log(LOG_ALL, LOG_TYPE_TEXT);
SQLConnection = mysql_connect(mysql_host,mysql_user,mysql_database,mysql_password);
if(SQLConnection && mysql_errno(SQLConnection) == 0)
{
print(“SQL: Server connection successful”);
}
else
{
print(“SQL ERROR: Could not connect to database, server shutting down.”);
SendRconCommand(“exit”);
}
//Checking if tables exist
new checkuquery[128],checkvquery[128],checkbquery[128];
mysql_format(SQLConnection,checkuquery,sizeof(checkuquery),”SHOW TABLES LIKE ‘cnr_users'”);
mysql_query(SQLConnection,checkuquery,true);
if(cache_get_row_count() == 0)
{
print(“SQL: Users table not found, creating it now.”);
new createuquery[256];
mysql_format(SQLConnection,createuquery,sizeof(createuquery),”CREATE TABLE cnr_users (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(22), password VARCHAR(129), ip VARCHAR(16), score INT(10), adminlevel INT(1), money INT(15), swat INT(1), PRIMARY KEY (id))”);
mysql_query(SQLConnection,createuquery,true);
}
else print(“SQL: Users table found.”);
mysql_format(SQLConnection,checkvquery,sizeof(checkvquery),”SHOW TABLES LIKE ‘cnr_vehicles'”);
mysql_query(SQLConnection,checkvquery,true);
if(cache_get_row_count() == 0)
{
print(“SQL: Vehicles table not found, creating it now.”);
new createvquery[256];
mysql_format(SQLConnection,createvquery,sizeof(createvquery),”CREATE TABLE cnr_vehicles (id INT NOT NULL AUTO_INCREMENT, modelid INT(3), xpos FLOAT, ypos FLOAT, zpos FLOAT, rotation FLOAT, color1 INT(3), color2 INT(3), PRIMARY KEY (id))”);
mysql_query(SQLConnection,createvquery,true);
}
else print(“SQL: Vehicles table found.”);
mysql_format(SQLConnection,checkbquery,sizeof(checkbquery),”SHOW TABLES LIKE ‘cnr_bans'”);
mysql_query(SQLConnection,checkbquery,true);
if(cache_get_row_count() == 0)
{
print(“SQL: Bans table not found, creating it now.”);
new createbquery[256];
mysql_format(SQLConnection,createbquery,sizeof(createbquery),”CREATE TABLE cnr_bans (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(22), ip VARCHAR(16), admin VARCHAR(22), reason VARCHAR(50), date VARCHAR(30), PRIMARY KEY (id))”);
mysql_query(SQLConnection,createbquery,true);
}
else print(“SQL: Bans table found.”);
//Grabbing vehicles from database
new aquery[128];
mysql_format(SQLConnection,aquery,sizeof(aquery),”SELECT * FROM `cnr_vehicles`”);
mysql_query(SQLConnection,aquery,true);
if(cache_get_row_count() > 0)
{
for(new i = 0; i < cache_get_row_count(); i++)
{
AddStaticVehicleEx(cache_get_field_content_int(i,”modelid”),cache_get_field_content_float(i,”xpos”),cache_get_field_content_float(i,”ypos”),cache_get_field_content_float(i,”zpos”),cache_get_field_content_float(i,”rotation”),cache_get_field_content_int(i,”color1″),cache_get_field_content_int(i,”color2″),120);
printf(“[VEHICLE LOADED] Vehicle model %d loaded at %f, %f, %f, Rotation: %f. (Colours: %d, %d)”,cache_get_field_content_int(i,”modelid”),cache_get_field_content_float(i,”xpos”),cache_get_field_content_float(i,”ypos”),cache_get_field_content_float(i,”zpos”),cache_get_field_content_float(i,”rotation”),cache_get_field_content_int(i,”color1″),cache_get_field_content_int(i,”color2″));
TotalVehicles++;
}
}
else print(“ERROR: Failed to load server vehicles from the sql database; no vehicles were found.”);
//Custom Patriots
CreateCustomPatriot(0,783.1301,-1348.1869,13.5392,90.0); //SAM
CreateCustomPatriot(1,783.1301,-1353.1869,13.5392,90.0); //Minigun
CreateCustomPatriot(2,783.3945,-1357.7914,13.5395,90.0); //M4
TotalVehicles += MAX_PATRIOTS;
//———–Classes———–//
//Cops
AddPlayerClass(280,0,0,0,0,0,0,0,0,0,0);
AddPlayerClass(266,0,0,0,0,0,0,0,0,0,0);
AddPlayerClass(265,0,0,0,0,0,0,0,0,0,0);
//Swat
AddPlayerClass(285,0,0,0,0,0,0,0,0,0,0);
//Civilians
AddPlayerClass(1,0,0,0,0,0,0,0,0,0,0);
AddPlayerClass(2,0,0,0,0,0,0,0,0,0,0);
AddPlayerClass(3,0,0,0,0,0,0,0,0,0,0);
AddPlayerClass(4,0,0,0,0,0,0,0,0,0,0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
switch(classid)
{
case 0..2: //Cops
{
GameTextForPlayer(playerid,”~n~~b~Police Officer”,5000,3);
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1537.8234,-1675.7080,13.5469);
SetPlayerFacingAngle(playerid,90.0);
SetPlayerCameraPos(playerid,1533.5883,-1675.8373,13.3828);
SetPlayerCameraLookAt(playerid,1537.8234,-1675.7080,13.5469);
PlayerInfo[playerid][Team] = 1;
}
case 3: //SWAT
{
GameTextForPlayer(playerid,”~n~~b~~h~~h~SWAT”,5000,3);
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,763.0967,-1353.3921,13.5225);
SetPlayerFacingAngle(playerid,268.3941);
SetPlayerCameraPos(playerid,763.0967+4.0,-1353.3921,13.5225+0.5);
SetPlayerCameraLookAt(playerid,763.0967,-1353.3921,13.5225);
PlayerInfo[playerid][Team] = 2;
}
case 4..7: //Civilians
{
GameTextForPlayer(playerid,”~n~~w~Civilian”,5000,3);
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1239.6534,-1385.6206,13.3722);
SetPlayerFacingAngle(playerid,180);
SetPlayerCameraPos(playerid,1239.6534,-1385.6206-4.0,13.3722+0.5);
SetPlayerCameraLookAt(playerid,1239.6534,-1385.6206,13.3722);
PlayerInfo[playerid][Team] = 0;
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
//Initial connection stuff
ResetPlayerVars(playerid);
ClearChatForPlayer(playerid);
GetPlayerName(playerid,PlayerInfo[playerid][Name],MAX_PLAYER_NAME);
GetPlayerIp(playerid,PlayerInfo[playerid][IP],16);
//Check if the player is banned
new query[256];
mysql_format(SQLConnection,query,sizeof(query),”SELECT `ip`,`name` FROM `cnr_bans` WHERE `ip`=’%s’ OR `name`=’%s'”,PlayerInfo[playerid][IP],PlayerInfo[playerid][Name]);
mysql_query(SQLConnection,query,true);
if(cache_get_row_count() != 0)
{
KickWithMessage(playerid, “You are banned from this server. Feel free to appeal the ban at www.code5gaming.com”);
return 1;
}
//Check if the player has an acc
new query2[128];
mysql_format(SQLConnection,query2,sizeof(query2),”SELECT `name` FROM `cnr_users` WHERE `name`=’%s'”,PlayerInfo[playerid][Name]);
mysql_query(SQLConnection,query2,true);
if(cache_get_row_count() != 0)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, “Login”, “This account is already registered, please login.”, “OK”, “Cancel”);
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, “Register”, “This account is not yet registered, please register it now by entering a password below.”, “OK”, “Cancel”);
}
SetPlayerTeam(playerid,NO_TEAM);
SetPlayerColor(playerid,COLOR_GRAY);
SendClientMessage(playerid, COLOR_BLUE, “==============================================================”);
SendClientMessage(playerid, COLOR_BLUE, “| Welcome to Billy’s basic Cops ‘n’ Robbers made for Mr.Alex |”);
SendClientMessage(playerid, COLOR_BLUE, “| You can view the commands using /cmds, have fun. |”);
SendClientMessage(playerid, COLOR_BLUE, “==============================================================”);
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), “%s(%d) has connected to the server.”,name,playerid);
SendClientMessageToAll(COLOR_GRAY, string);
InterpolateCameraPos(playerid,619.4519,-2193.5303,77.2241,685.5873,-1810.9756,69.5154,30000, CAMERA_MOVE);
InterpolateCameraLookAt(playerid,685.5873,-1810.9756,69.5154,685.5873,-1810.9756,69.5154,10000);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayerStats(playerid);
ResetPlayerVars(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
switch(PlayerInfo[playerid][Team])
{
case 0: //Civilian
{
SetPlayerColor(playerid,COLOR_WHITE);
SetPlayerTeam(playerid,NO_TEAM);
new spawn = random(sizeof(CivilianSpawns));
SetPlayerPos(playerid,CivilianSpawns[spawn][0],CivilianSpawns[spawn][1],CivilianSpawns[spawn][2]);
GivePlayerWeapon(playerid,24,250);
GivePlayerWeapon(playerid,30,250);
}
case 1: //Cop
{
SetPlayerColor(playerid,COLOR_BLUE);
SetPlayerTeam(playerid,1);
new spawn = random(sizeof(CopSpawns));
SetPlayerPos(playerid,CopSpawns[spawn][0],CopSpawns[spawn][1],CopSpawns[spawn][2]);
GivePlayerWeapon(playerid,24,250);
GivePlayerWeapon(playerid,27,250);
GivePlayerWeapon(playerid,31,250);
SetPlayerArmour(playerid,50.0);
}
case 2: //SWAT
{
SetPlayerColor(playerid,COLOR_SWAT);
SetPlayerTeam(playerid,1);
new spawn = random(sizeof(SWATSpawns));
SetPlayerPos(playerid,SWATSpawns[spawn][0],SWATSpawns[spawn][1],SWATSpawns[spawn][2]);
GivePlayerWeapon(playerid,24,500);
GivePlayerWeapon(playerid,27,500);
GivePlayerWeapon(playerid,31,500);
GivePlayerWeapon(playerid,29,500);
GivePlayerWeapon(playerid,34,500);
SetPlayerArmour(playerid,100.0);
}
}
GameTextForPlayer(playerid,” “,1,3);
SetPlayerHealth(playerid,100.0);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid,0);
PlayerInfo[playerid][Spawned] = 1;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid,playerid,reason);
PlayerInfo[playerid][Spawned] = 0;
if(PlayerInfo[playerid][RecentlyRaped] == 1)
{
KillTimer(RapeDamageTime[playerid]);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_YES)
{
if(PlayerInfo[playerid][Team] == 1)
{
if(IsPlayerInRangeOfPoint(playerid,10.0,1588.66699, -1637.86975, 14.97660))
{
MoveObject(Police_Gate,1588.66699, -1637.86975, 14.97660-7.5,4.00);
if(PoliceGateCheck)
{
KillTimer(PoliceGateTimer);
}
PoliceGateTimer = SetTimer(“PoliceGate”,7500,false);
PoliceGateCheck++;
}
}
else if(PlayerInfo[playerid][Team] == 2)
{
if(IsPlayerInRangeOfPoint(playerid,10.0,778.15979, -1384.83679, 14.23520))
{
MoveObject(SWAT_Gate1,778.15979, -1384.83679, 14.23520-5.0,4.00);
if(SwatGate1Check)
{
KillTimer(SwatGate1Timer);
}
SwatGate1Timer = SetTimer(“SwatGate1”,7500,false);
SwatGate1Check++;
}
else if(IsPlayerInRangeOfPoint(playerid,10.0,777.87622, -1330.33008, 14.02322))
{
MoveObject(SWAT_Gate2,777.87622, -1330.33008, 14.02322-5.0,4.00);
if(SwatGate2Check)
{
KillTimer(SwatGate2Timer);
}
SwatGate2Timer = SetTimer(“SwatGate2”,7500,false);
SwatGate2Check++;
}
}
}
if(newkeys & KEY_FIRE)
{
for(new i = 0; i < MAX_PATRIOTS; i++)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) == PatriotInfo[i][vehid] && GetPlayerVehicleSeat(playerid) == 0)
{
switch(PatriotInfo[i][ptype])
{
case 0: //Sam
{
if(PlayerInfo[playerid][SamRec] != 1)
{
PlayerInfo[playerid][SamRec] = 1;
SetTimerEx(“SamRecTimer”,30000,false,”i”,playerid);
for(new a = 0; a < MAX_PLAYERS; a++)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
if(IsPlayerConnected(a) && IsPlayerInRangeOfPoint(a,200.0,x,y,z))
{
if(IsPlayerInAircraft(a))
{
new Float:x2,Float:y2,Float:z2;
GetPlayerPos(a,x2,y2,z2);
SendClientMessage(playerid,COLOR_YELLOW,”SAM: Missle locked onto aircraft, firing now!”);
SetVehicleHealth(GetPlayerVehicleID(a),240.0);
CreateExplosion(x2,y2,z2,3,15.0);
SetPlayerHealth(a,0.0);
SendClientMessage(a,COLOR_RED,”You were shot down by a SWAT Patriot’s SAM missile.”);
}
else
{
SendClientMessage(playerid,COLOR_RED,”ERROR: No aicraft in range were found.”);
}
}
}
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: SAM site recently used.”);
}
case 1: //Miniguns
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PlayerPlaySound(playerid,1135,x,y,z);
PatriotInfo[i][gunflash1] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash1],PatriotInfo[i][vehid],-0.824999,2.175000,-0.974999,0,0,0);
PatriotInfo[i][gunflash2] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash2],PatriotInfo[i][vehid],0.824999,2.175000,-0.974999,0,0,0);
PlayerInfo[playerid][Firing] = 1;
if(ShootTimerActive[playerid] == 0)
{
SetTimerEx(“PatriotShootTimer”,100,true,”i”,playerid);
ShootTimer[playerid] = ShootTimerActive[playerid] = 1;
}
}
case 2: //M4s
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PlayerPlaySound(playerid,1135,x,y,z);
PatriotInfo[i][gunflash1] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash1],PatriotInfo[i][vehid],-1.200000,1.950000,-1.275000,0,0,0);
PatriotInfo[i][gunflash2] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash2],PatriotInfo[i][vehid],1.200000,1.950000,-1.275000,0,0,0);
PlayerInfo[playerid][Firing] = 1;
if(ShootTimerActive[playerid] == 0)
{
SetTimerEx(“PatriotShootTimer”,100,true,”i”,playerid);
ShootTimer[playerid] = ShootTimerActive[playerid] = 1;
}
}
}
}
}
}
}
if(RELEASED(KEY_FIRE))
{
if(PlayerInfo[playerid][Firing] == 1)
{
for(new i = 0; i < MAX_PATRIOTS; i++)
{
if(GetPlayerVehicleID(playerid) == PatriotInfo[i][vehid])
{
PatriotRemoveGunFlashes(i);
PlayerInfo[playerid][Firing] = 0;
}
}
}
}
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(PlayerInfo[playerid][Team] == 2 && PlayerInfo[playerid][SWAT] != 1)
{
SendClientMessage(playerid,COLOR_RED,”ERROR: You must be invited to this class in order to use it.”);
return 0;
}
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(success)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(strcmp(ip,PlayerInfo[i][IP])) continue;
PlayerInfo[i][AdminLevel] = 7;
}
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
if(strlen(inputtext) < 6 || strlen(inputtext) > 25)
{
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD , “Register”, “This account is not yet registered, please register it now by entering a password below.\n{DECC45}ERROR: Password must be 6-25 characters!”, “OK”, “Leave”);
}
new query[300],query2[300], lepass[256], lemessage[256],buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
mysql_escape_string(buf,lepass);
mysql_format(SQLConnection,query,sizeof(query),”INSERT INTO `cnr_users` (`name`,`password`) VALUES (‘%s’,’%s’)”,PlayerInfo[playerid][Name],lepass);
mysql_query(SQLConnection,query, true);
format(lemessage,sizeof(lemessage),”You have succesfuly registered your account! (Name: %s | Password: %s)”,PlayerInfo[playerid][Name],inputtext);
SendClientMessage(playerid,COLOR_GREEN,lemessage);
printf(“[REGISTRATION] %s(%d) [%s] has successfuly registered their account.”,PlayerInfo[playerid][Name], playerid, PlayerInfo[playerid][IP]);
PlayerInfo[playerid][LoggedIn] = 1;
mysql_format(SQLConnection,query2,sizeof(query2),”SELECT `id` FROM `cnr_users` WHERE `name`=’%s'”,PlayerInfo[playerid][Name]);
mysql_query(SQLConnection,query2, true);
if(cache_get_row_count() > 0)
{
PlayerInfo[playerid][SQLID] = cache_get_field_content_int(0,”id”);
}
else print(“SQL ERROR: Registration error, cannot find SQL ID.”);
}
else
{
KickWithMessage(playerid,”You have been kicked for failing to register your account.”);
}
return 1;
}
else if(dialogid == DIALOG_LOGIN)
{
if(response)
{
new query[300], lepass[129],buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
mysql_escape_string(buf,lepass);
mysql_format(SQLConnection,query,sizeof(query),”SELECT * FROM `cnr_users` WHERE `name`=’%s’ AND `password`=’%s'”,PlayerInfo[playerid][Name],lepass);
mysql_query(SQLConnection,query,true);
if(cache_get_row_count() == 0) //Login not sucessful
{
if(GetPVarInt(playerid,”LogAttempts”) < 3)
{
SetPVarInt(playerid,”LogAttempts”,GetPVarInt(playerid,”LogAttempts”)+1);
printf(“[LOGIN] %s(%d) [%s] has entered an invalid password!”,PlayerInfo[playerid][Name], playerid, PlayerInfo[playerid][IP]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD , “Login”, “This account is registered, please login.\n{DECC45}ERROR: Incorrect password!”, “OK”, “Cancel”);
}
else
{
KickWithMessage(playerid,”You have been kicked exceeding the maximum number of login attempts.”);
}
}
else //Login sucessful
{
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][SQLID] = cache_get_field_content_int(0,”id”);
PlayerInfo[playerid][AdminLevel] = cache_get_field_content_int(0,”adminlevel”);
PlayerInfo[playerid][SWAT] = cache_get_field_content_int(0,”swat”);
GivePlayerMoneyEx(playerid,cache_get_field_content_int(0,”money”));
SetPlayerScore(playerid,cache_get_field_content_int(0,”score”));
SendClientMessage(playerid,COLOR_GREEN,”You have succesfuly logged into your account.”);
printf(“[LOGIN] %s(%d) [%s] has successfuly logged into their account.”,PlayerInfo[playerid][Name], playerid, PlayerInfo[playerid][IP]);
}
}
else
{
KickWithMessage(playerid,”You have been kicked for failing to login to your account.”);
}
return 1;
}
else if(dialogid == DIALOG_MENU)
{
if(response)
{
switch(listitem)
{
case 0: //Teleports
{
ShowPlayerDialog(playerid,DIALOG_TELEPORTS,DIALOG_STYLE_LIST,”Menu – Teleports”,”Los Santos\nLas Venturas\nSan Fierro\nArea 51\nRC Battlefield”, “OK”, “Back”);
}
case 1: //Refill health/armour
{
SetPlayerHealth(playerid,100.0);
SetPlayerArmour(playerid,100.0);
SendClientMessage(playerid,COLOR_GREEN,”Health and armour refilled.”);
}
case 2: //Weapons
{
GivePlayerWeapon(playerid,24,1000);
GivePlayerWeapon(playerid,31,1000);
GivePlayerWeapon(playerid,34,1000);
GivePlayerWeapon(playerid,27,1000);
GivePlayerWeapon(playerid,29,1000);
SendClientMessage(playerid,COLOR_YELLOW,”Weapons given.”);
}
}
}
}
else if(dialogid == DIALOG_TELEPORTS)
{
if(response)
{
switch(listitem)
{
case 0: //LS
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1479.9652,-1710.1757,14.0469);
}
case 1: //LV
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,2085.1018,1683.6785,10.8203);
}
case 2: //SF
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,-1980.3431,487.2232,35.1719);
}
case 3: //A51
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,213.2303,1909.0466,17.6406);
}
case 4: //RCBF
{
SetPlayerInterior(playerid,10);
SetPlayerPos(playerid,-1131.1152,1057.6246,1346.4165);
}
}
SendClientMessage(playerid,COLOR_GRAY,”Teleported.”);
}
else
{
ShowPlayerDialog(playerid, DIALOG_MENU, DIALOG_STYLE_LIST, “Menu”, “Teleports\nHeal\nWeapons”, “OK”, “Cancel”);
}
}
return 1;
}
//———————-Commands———————-//
// //
//——————Regular Commands——————//
CMD:commands(playerid,params[])
{
SendClientMessage(playerid,COLOR_GRAY,”Basic Commands: /stats, /menu, /spawnme, /kill”);
switch(PlayerInfo[playerid][Team])
{
case 0: //Civilian
{
SendClientMessage(playerid,COLOR_WHITE,”Civilian Commands: /rob, /rape”);
}
case 1: //Cop
{
SendClientMessage(playerid,COLOR_BLUE,”Police Commands: /cuff, /arrest”);
}
case 2: //SWAT
{
SendClientMessage(playerid,COLOR_SWAT,”SWAT Commands: /cuff, /arrest”);
}
}
return 1;
}
CMD:cmds(playerid, params[]) return cmd_commands(playerid, params);
//
CMD:stats(playerid,params[])
{
new line1[128],line2[128];
format(line1,sizeof(line1),”[__________________%s’s Statistics__________________]”,PlayerInfo[playerid][Name]);
format(line2,sizeof(line2),”Name: %s | Admin Level: %d | Score: %d | Money: $%d | SWAT: %s”,PlayerInfo[playerid][Name],PlayerInfo[playerid][AdminLevel],GetPlayerScore(playerid),PlayerInfo[playerid][Money],CheckSWAT(playerid));
SendClientMessage(playerid,COLOR_WHITE,line1);
SendClientMessage(playerid,COLOR_WHITE,line2);
return 1;
}
CMD:menu(playerid,params[])
{
ShowPlayerDialog(playerid, DIALOG_MENU, DIALOG_STYLE_LIST, “Menu”, “Teleports\nHeal\nWeapons”, “OK”, “Cancel”);
return 1;
}
CMD:spawnme(playerid,params[])
{
if(PlayerInfo[playerid][Spawned] == 1)
{
SpawnPlayer(playerid);
SendClientMessage(playerid,COLOR_GRAY,”Spawned.”);
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: You must be already spawned to use this command.”);
return 1;
}
CMD:kill(playerid,params[])
{
SetPlayerHealth(playerid,0);
SendClientMessage(playerid,COLOR_GRAY,”Killed.”);
return 1;
}
CMD:lotto(playerid,params[])
{
new lnumber;
if(sscanf(params,”d”,lnumber)) return SendUsage(playerid,”Usage: /lotto (number 1-5)”);
if(lnumber < 1 || lnumber > 5) return SendClientMessage(playerid,COLOR_RED,”ERROR: Invalid lotto number (1-5).”);
if(PlayerInfo[playerid][LottoNum] > 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are already playing the lotto!”);
if(PlayerInfo[playerid][Money] < 500) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot afford to participate in the lotto!”);
if(LottoOnGoing != 1) //No ongoing lotto, start new one
{
new astring[128],astring2[128];
LottoPrize = random(50000)+50000;
format(astring,sizeof(astring),”A new lotto has been started by %s(%d)! Use /lotto (number) to participate in the lotto!”,PlayerInfo[playerid][Name],playerid);
format(astring2,sizeof(astring2),”The prize is $%d! The draw will be done in 5 minutes.”,LottoPrize);
SendClientMessageToAll(COLOR_YELLOW,astring);
SendClientMessageToAll(COLOR_YELLOW,astring2);
printf(“[LOTTO] %s(%d) has started a lotto.”,PlayerInfo[playerid][Name],playerid);
LottoOnGoing = 1;
}
PlayerInfo[playerid][LottoNum] = lnumber;
GivePlayerMoneyEx(playerid,-500);
new pstring[128];
format(pstring,sizeof(pstring),”You have purchased lotto ticket number %d for $500.”,lnumber);
SendClientMessage(playerid,COLOR_GREEN,pstring);
SetTimer(“LottoDraw”,300000,false);
return 1;
}
//—————End of Regular Commands—————//
// //
//——————Civilian Commands——————//
CMD:rob(playerid,params[])
{
if(PlayerInfo[playerid][Team] == 0)
{
new targetid,Float:x,Float:y,Float:z;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /rob (player)”);
if(PlayerInfo[targetid][RecentlyRobbed] == 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: This player was recently robbed.”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
GetPlayerPos(targetid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are not close enough to this player to rob them.”);
new pstring[128],tstring[128],cashtaken = random(30000)+20000;
if(PlayerInfo[targetid][Money] < cashtaken)
{
cashtaken = PlayerInfo[targetid][Money];
}
format(pstring,sizeof(pstring),”Robbery: You have robbed %d from %s(%d)’s wallet.”,cashtaken,PlayerInfo[targetid][Name],targetid);
format(tstring,sizeof(tstring),”Robbery: %s(%d) has robbed %d from your wallet.”,PlayerInfo[playerid][Name],playerid,cashtaken);
GivePlayerMoneyEx(playerid,cashtaken);
GivePlayerMoneyEx(targetid,-cashtaken);
SendClientMessage(playerid,COLOR_RED,pstring);
SendClientMessage(targetid,COLOR_RED,tstring);
PlayerInfo[targetid][RecentlyRobbed] = 1;
SetTimerEx(“RobTimer”,60000,false,”i”,targetid);
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: You must be a civilian in order to use this command.”);
return 1;
}
CMD:rape(playerid,params[])
{
if(PlayerInfo[playerid][Team] == 0)
{
new targetid,Float:x,Float:y,Float:z;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /rape (player)”);
if(PlayerInfo[targetid][RecentlyRaped] == 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: This player was recetnly raped.”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
GetPlayerPos(targetid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are not close enough to this player to rape them.”);
new pstring[128],tstring[128];
format(pstring,sizeof(pstring),”Rape: You have raped %s(%d) and given them a couple STDs.”,PlayerInfo[targetid][Name],targetid);
format(tstring,sizeof(tstring),”Rape: %s(%d) has raped you. You are now infected with STDs.”,PlayerInfo[playerid][Name],playerid);
SendClientMessage(playerid,COLOR_RED,pstring);
SendClientMessage(targetid,COLOR_RED,tstring);
PlayerInfo[targetid][RecentlyRaped] = 1;
SetTimerEx(“RapeTimer”,60000,false,”i”,targetid);
RapeDamageTime[targetid] = SetTimerEx(“RapeDamageTimer”,5000,true,”i”,targetid);
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: You must be a civilian in order to use this command.”);
return 1;
}
//————–End of Civilian Commands————–//
// //
//——————Police Commands——————//
CMD:cuff(playerid,params[])
{
if(PlayerInfo[playerid][Team] > 0)
{
new targetid,Float:x,Float:y,Float:z;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /cuff (player)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][Team] > 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot cuff another Law Enforcement Officer.”);
GetPlayerPos(targetid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are not close enough to this player to cuff them.”);
if(PlayerInfo[targetid][Cuffed] == 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: This player is already cuffed!”);
new pstring[128],tstring[128];
format(pstring,sizeof(pstring),”You have cuffed %s(%d).”,PlayerInfo[targetid][Name],targetid);
format(tstring,sizeof(tstring),”Law Enforcement Officer %s(%d) has placed you in hand cuffs.”,PlayerInfo[playerid][Name],playerid);
SendClientMessage(playerid,COLOR_RED,pstring);
SendClientMessage(targetid,COLOR_RED,tstring);
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);
PlayerInfo[targetid][Cuffed] = 1;
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: You must be a Law Enforcement Officer in order to use this command.”);
return 1;
}
CMD:arrest(playerid,params[])
{
if(PlayerInfo[playerid][Team] > 0)
{
new targetid,Float:x,Float:y,Float:z;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /arrest (player)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][Team] > 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot arrest another Law Enforcement Officer.”);
GetPlayerPos(targetid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are not close enough to this player to arrest them.”);
if(PlayerInfo[targetid][Cuffed] == 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: This player must be cuffed before they can be arrested.”);
if(PlayerInfo[targetid][Arrested] == 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: This player is already arrested.”);
new pstring[128],tstring[128];
format(pstring,sizeof(pstring),”You have arrested %s(%d).”,PlayerInfo[targetid][Name],targetid);
format(tstring,sizeof(tstring),”You have been arrested by %s(%d) and sent to jail.”,PlayerInfo[playerid][Name],playerid);
SendClientMessage(playerid,COLOR_RED,pstring);
SendClientMessage(targetid,COLOR_RED,tstring);
PlayerInfo[targetid][Cuffed] = 0;
PlayerInfo[targetid][Arrested] = 1;
SetPlayerInterior(targetid,6);
SetPlayerPos(targetid,215.5074,110.6161,999.0156);
SetTimerEx(“UnJail”,30000,false,”i”,targetid);
}
else SendClientMessage(playerid,COLOR_RED,”ERROR: You must be a Law Enforcement Officer in order to use this command.”);
return 1;
}
CMD:ar(playerid, params[]) return cmd_arrest(playerid, params);
//—————End of Police Commands—————//
// //
//—————End of Regular Commands————–//
// //
//——————-Admin Commands——————-//
CMD:acmds(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] > 0)
{
SendClientMessage(playerid,COLOR_GRAY,”Admin commands: /kick, /ban, /setscore, /giveallscore, /setadminlevel, /savecar, /giveswat, /takeswat, /v, /amoney”);
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:admincommands(playerid, params[]) return cmd_acmds(playerid, params);
//
CMD:kick(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
new targetid,reason[50];
if(sscanf(params,”us”,targetid,reason)) return SendUsage(playerid,”Usage: /kick (playerid) (reason)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][AdminLevel] >= PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot kick a higher/equal leveled admin.”);
new astring[128],pstring[128],tstring[128];
format(astring,sizeof(astring),”[KICK] Administrator %s(%d) has kicked %s(%d) from the server for: %s”,PlayerInfo[playerid][Name],playerid,PlayerInfo[targetid][Name],targetid,reason);
format(pstring,sizeof(pstring),”You have kicked %s(%d) from the server, reason: %s”,PlayerInfo[targetid][Name],targetid,reason);
format(tstring,sizeof(tstring),”You have been kicked from the server by administrator %s with the reason of: %s.”,PlayerInfo[playerid][Name],reason);
SendClientMessageToAll(COLOR_RED,astring);
SendClientMessage(playerid,COLOR_BLUE,pstring);
KickWithMessage(targetid,tstring);
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:ban(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 2)
{
new targetid,reason[50];
if(sscanf(params,”us[50]”,targetid,reason)) return SendUsage(playerid,”Usage: /ban (playerid) (reason)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][AdminLevel] > PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot use this command on a higher leveled administrator.”);
new astring[128],pstring[128],tstring[128],year,month,day,hour,minute,second,datetime[20],query[256];
getdate(year,month,day);
gettime(hour,minute,second);
format(astring,sizeof(astring),”[BAN] Administrator %s(%d) has banned %s(%d) from the server for: %s”,PlayerInfo[playerid][Name],playerid,PlayerInfo[targetid][Name],targetid,reason);
format(pstring,sizeof(pstring),”You have banned %s(%d) from the server, reason: %s”,PlayerInfo[targetid][Name],targetid,reason);
format(tstring,sizeof(tstring),”You have been banned from the server by administrator %s with the reason of %s. (%i/%i/%i) (%i:%i:%i)”,PlayerInfo[playerid][Name],reason,day,month,year,hour,minute,second);
SendClientMessageToAll(COLOR_RED,astring);
SendClientMessage(playerid,COLOR_BLUE,pstring);
KickWithMessage(targetid,tstring);
format(datetime,sizeof(datetime), “%i-%i-%i %i:%i:%i”,day,month,year,hour,minute,second);
mysql_format(SQLConnection,query,sizeof(query),”INSERT INTO `cnr_bans` (`name`,`ip`,`admin`,`reason`,`date`) VALUES (‘%s’,’%s’,’%s’,’%s’,’%s’)”,PlayerInfo[targetid][Name],PlayerInfo[targetid][IP],PlayerInfo[playerid][Name],reason,datetime);
mysql_query(SQLConnection,query,true);
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:setadminlevel(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 5)
{
new targetid,alevel;
if(sscanf(params,”ud”,targetid,alevel)) return SendUsage(playerid,”Usage: /setadminlevel (playerid) (admin level)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(alevel < 0 || alevel > 7) return SendClientMessage(playerid,COLOR_RED,”ERROR: You have entered an invalid admin level.”);
if(alevel > PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot give someone an admin level higher than that of your own.”);
if(PlayerInfo[targetid][AdminLevel] == alevel) return SendClientMessage(playerid,COLOR_RED,”ERROR: That player already has the admin level you specified.”);
if(PlayerInfo[targetid][AdminLevel] > PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_RED,”ERROR: You cannot change the admin level of someone with a higher admin level than yourself.”);
new pstring[128],tstring[128];
format(tstring,sizeof(tstring),”Administrator %s(%d) has set your admin level to %d.”,PlayerInfo[playerid][Name],playerid,alevel);
format(pstring,sizeof(pstring),”You have set %s(%d)’s admin level to %d.”,PlayerInfo[targetid][Name],targetid,alevel);
SendClientMessage(playerid,COLOR_BLUE,pstring);
SendClientMessage(targetid,COLOR_GREEN,tstring);
if(PlayerInfo[targetid][AdminLevel] < alevel)
{
SendClientMessage(targetid,COLOR_GREEN,”Congratulations on your promotion! You can use /acmds to view your new commands.”);
GameTextForPlayer(targetid, “~g~Promoted”, 3000, 4);
}
else
{
GameTextForPlayer(targetid, “~r~Demoted”, 3000, 4);
SendClientMessage(targetid,COLOR_RED,”You have been demoted, you clearly fucked up somehow.”);
}
PlayerInfo[targetid][AdminLevel] = alevel;
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:setscore(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 5 || IsPlayerAdmin(playerid))
{
new targetid,score;
if(sscanf(params,”ud”,targetid,score)) return SendUsage(playerid,”Usage: /setadminlevel (playerid) (score)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
new pstring[128],tstring[128];
format(tstring,sizeof(tstring),”Administrator %s(%d) has set your score to %d.”,PlayerInfo[playerid][Name],playerid,score);
format(pstring,sizeof(pstring),”You have set %s(%d)’s score to %d.”,PlayerInfo[targetid][Name],targetid,score);
SendClientMessage(playerid,COLOR_BLUE,pstring);
SendClientMessage(targetid,COLOR_GREEN,tstring);
SetPlayerScore(targetid,score);
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:giveallscore(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 3)
{
new score,astring[128],pstring[128];
if(sscanf(params,”d”,score)) return SendUsage(playerid,”Usage: /giveallscore (amount of score)”);
if(score > 1000 || score < 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: Invalid amount of score (0-1000).”);
format(pstring,sizeof(pstring),”You have given all players %d score.”,score);
format(astring,sizeof(astring),”Administrator %s(%d) has given all players %d score.”,PlayerInfo[playerid][Name],playerid,score);
SendClientMessage(playerid,COLOR_BLUE,pstring);
SendClientMessageToAll(COLOR_YELLOW,astring);
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerScore(i,GetPlayerScore(i)+score);
}
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:savecar(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 5)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,”ERROR: You are not in a vehicle to save.”);
new pstring[128],veh = GetPlayerVehicleID(playerid),vmodel = GetVehicleModel(veh),Float:rotation,Float:x,Float:y,Float:z,query[256],color1,color2;
if(sscanf(params,”dd”,color1,color2)) return SendUsage(playerid,”Usage: /savecar (color 1) (color 2)”);
GetVehicleZAngle(veh,rotation);
GetVehiclePos(veh,x,y,z);
format(pstring,sizeof(pstring),”You have saved a (%d) at %f | %f | %f | Rotation: %f | Colours: %d, %d”,vmodel,x,y,z,rotation,color1,color2);
SendClientMessage(playerid,COLOR_YELLOW,pstring);
mysql_format(SQLConnection,query,sizeof(query),”INSERT INTO `cnr_vehicles` (`modelid`,`xpos`,`ypos`,`zpos`,`rotation`,`color1`,`color2`) VALUES (‘%d’,’%f’,’%f’,’%f’,’%f’,’%d’,’%d’)”,vmodel,x,y,z,rotation,color1,color2);
mysql_query(SQLConnection,query, true);
printf(“[VEHICLE SAVE] Vehicle (%d) saved at %f | %f | %f | Rotation: %f | Colours: %d, %d”,vmodel,x,y,z,rotation,color1,color2);
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:v(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
new veh[50];
if(PlayerInfo[playerid][Spawned] != 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: You must be spawned in order to use this command.”);
if(sscanf(params,”s[50]”,veh)) return SendUsage(playerid,”Usage: /v (vehicle name)”);
new leveh = GetVehicleModelFromName(veh);
if(leveh > 611 || leveh < 400) return SendClientMessage(playerid,COLOR_RED,”ERROR: You have entered an invalid vehicle name.”);
if(PlayerInfo[playerid][V] != -1) DestroyVehicle(PlayerInfo[playerid][V]);
new Float:x,Float:y,Float:z,Float:angle;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,angle);
PlayerInfo[playerid][V] = CreateVehicle(leveh,x,y,z + 2,angle,0,0,500);
PutPlayerInVehicle(playerid,PlayerInfo[playerid][V],0);
LinkVehicleToInterior(PlayerInfo[playerid][V],GetPlayerInterior(playerid));
SetVehicleVirtualWorld(PlayerInfo[playerid][V],GetPlayerVirtualWorld(playerid));
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:giveswat(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 2)
{
new targetid;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /giveswat (player)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][SWAT] == 1) return SendClientMessage(playerid,COLOR_RED,”ERROR: This person is already a SWAT member.”);
new astring[128],pstring[128];
format(pstring,sizeof(pstring),”Administrator %s(%d) has given you the SWAT status.”,PlayerInfo[playerid][Name],playerid);
format(astring,sizeof(astring),”You have given %s(%d) the SWAT status.”,PlayerInfo[targetid][Name],targetid);
SendClientMessage(playerid,COLOR_YELLOW,astring);
SendClientMessage(targetid,COLOR_GREEN,pstring);
PlayerInfo[targetid][SWAT] = 1;
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:takeswat(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 2)
{
new targetid;
if(sscanf(params,”u”,targetid)) return SendUsage(playerid,”Usage: /takeswat (player)”);
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendInvalidPlayer(playerid);
if(PlayerInfo[targetid][SWAT] == 0) return SendClientMessage(playerid,COLOR_RED,”ERROR: This person is not a SWAT member.”);
new astring[128],pstring[128];
format(pstring,sizeof(pstring),”Administrator %s(%d) has revoked your SWAT status.”,PlayerInfo[playerid][Name],playerid);
format(astring,sizeof(astring),”You have revoked %s(%d)’s SWAT status.”,PlayerInfo[targetid][Name],targetid);
SendClientMessage(playerid,COLOR_YELLOW,astring);
SendClientMessage(targetid,COLOR_RED,pstring);
PlayerInfo[targetid][SWAT] = 0;
}
else SendNotAuthorized(playerid);
return 1;
}
CMD:amoney(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
GivePlayerMoneyEx(playerid,500000);
SendClientMessage(playerid,COLOR_GREEN,”Money given.”);
}
else SendNotAuthorized(playerid);
return 1;
}
//————–End of Admin Commands————–//
// //
//———————Timers———————//
public FiveMinutes() //Five minute timer
{
new totalp;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerScore(i,GetPlayerScore(i)+5);
totalp++;
SavePlayerStats(i);
}
}
SendClientMessageToAll(COLOR_YELLOW,”Five minutes has passed! Everyone has been given 5 score!”);
printf(“[5 Minutes] Players online: %d | Total score given out: %d”,totalp,totalp*5);
totalp = 0;
}
public LottoDraw() //Lotto prize draw
{
new drawnum = random(5)+1, numwinners;
LottoOnGoing = 0;
numwinners = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][LottoNum] == drawnum)
{
new astring[128];
format(astring,sizeof(astring),”Lotto Draw: Congratulations to %s(%d) for winning the lottery with the number %d! They have won a prize of %d!”,PlayerInfo[i][Name],i,drawnum,LottoPrize);
SendClientMessageToAll(COLOR_YELLOW,astring);
GivePlayerMoneyEx(i,LottoPrize);
numwinners++;
printf(“[LOTTO] %s(%d) won %d from the lotto.”,PlayerInfo[i][Name],i,LottoPrize);
}
else
{
SendClientMessage(i,COLOR_RED,”Unfortunately you didn’t win anything from the lottery, better luck next time!”);
}
PlayerInfo[i][LottoNum] = 0;
}
}
if(numwinners == 0)
{
new astring[128];
format(astring,sizeof(astring),”No-one won the lottery! The winning number was %d.”,drawnum);
SendClientMessageToAll(COLOR_RED,astring);
}
LottoPrize = 0;
}
public PoliceGate() //Police gate up
{
new numinrange;
PoliceGateCheck–;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][Team] == 1)
{
if(IsPlayerInRangeOfPoint(i,5.0,1588.66699, -1637.86975, 14.97660))
{
numinrange++;
}
}
}
if(numinrange == 0)
{
MoveObject(Police_Gate,1588.66699, -1637.86975, 14.97660,4.00);
}
else
{
PoliceGateTimer = SetTimer(“PoliceGate”,7500,false);
PoliceGateCheck++;
}
numinrange = 0;
}
public SwatGate1()
{
new numinrange;
SwatGate1Check–;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][Team] == 2)
{
if(IsPlayerInRangeOfPoint(i,5.0,778.15979, -1384.83679, 14.23520))
{
numinrange++;
}
}
}
if(numinrange == 0)
{
MoveObject(SWAT_Gate1,778.15979, -1384.83679, 14.23520,4.00);
}
else
{
SwatGate1Timer = SetTimer(“SwatGate1”,7500,false);
SwatGate1Check++;
}
numinrange = 0;
}
public SwatGate2()
{
new numinrange;
SwatGate2Check–;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][Team] == 2)
{
if(IsPlayerInRangeOfPoint(i,5.0,777.87622, -1330.33008, 14.02322))
{
numinrange++;
}
}
}
if(numinrange == 0)
{
MoveObject(SWAT_Gate2,777.87622, -1330.33008, 14.02322,4.00);
}
else
{
SwatGate2Timer = SetTimer(“SwatGate2”,7500,false);
SwatGate2Check++;
}
numinrange = 0;
}
public RobTimer(playerid)
{
PlayerInfo[playerid][RecentlyRobbed] = 0;
}
public RapeTimer(playerid)
{
PlayerInfo[playerid][RecentlyRaped] = 0;
}
public RapeDamageTimer(playerid)
{
new count, Float:phealth;
GetPlayerHealth(playerid,phealth);
SetPlayerHealth(playerid,phealth – 10.0);
count++;
if(count >= 10)
{
KillTimer(RapeDamageTime[playerid]);
}
}
public UnJail(playerid)
{
PlayerInfo[playerid][Cuffed] = 0;
PlayerInfo[playerid][Arrested] = 0;
SpawnPlayer(playerid);
}
public SamRecTimer(playerid)
{
PlayerInfo[playerid][SamRec] = 0;
}
public PatriotShootTimer(playerid)
{
if(PlayerInfo[playerid][Firing] == 1)
{
new count = 0;
for(new i = 0; i < MAX_PATRIOTS; i++)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == PatriotInfo[i][vehid])
{
if(PatriotInfo[i][ptype] == 1) //Minigun
{
count++;
PatriotRemoveGunFlashes(i);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PlayerPlaySound(playerid,1135,x,y,z);
PatriotInfo[i][gunflash1] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash1],PatriotInfo[i][vehid],-0.824999,2.175000,-0.974999,0,0,0);
PatriotInfo[i][gunflash2] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash2],PatriotInfo[i][vehid],0.824999,2.175000,-0.974999,0,0,0);
GetXYInFrontOfPlayer(playerid,x,y,10.0);
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
if(IsPlayerInRangeOfPoint(p,PATRIOT_MAX_SHOOT_DISTANCE,x,y,z) && playerid != p)
{
if(IsPlayerInAnyVehicle(p))
{
new Float:vhealth;
GetVehicleHealth(GetPlayerVehicleID(p),vhealth);
SetVehicleHealth(GetPlayerVehicleID(p),vhealth – PATRIOT_MINIGUN_VEHICLE_DAMAGE);
}
else
{
new Float:phealth;
GetPlayerHealth(p,phealth);
SetPlayerHealth(p,phealth – PATRIOT_MINIGUN_PLAYER_DAMAGE);
}
}
PlayerPlaySound(p,1135,0,0,0);
}
}
}
else if(PatriotInfo[i][ptype] == 2) //M4
{
count++;
PatriotRemoveGunFlashes(i);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PlayerPlaySound(playerid,1135,x,y,z);
PatriotInfo[i][gunflash1] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash1],PatriotInfo[i][vehid],-1.200000,1.950000,-1.275000,0,0,0);
PatriotInfo[i][gunflash2] = CreateObject(18695,0,0,0,0,0,0,0);
AttachObjectToVehicle(PatriotInfo[i][gunflash2],PatriotInfo[i][vehid],1.200000,1.950000,-1.275000,0,0,0);
GetXYInFrontOfPlayer(playerid,x,y,10.0);
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(IsPlayerConnected(p))
{
if(IsPlayerInRangeOfPoint(p,PATRIOT_MAX_SHOOT_DISTANCE,x,y,z) && playerid != p)
{
if(IsPlayerInAnyVehicle(p))
{
new Float:vhealth;
GetVehicleHealth(GetPlayerVehicleID(p),vhealth);
SetVehicleHealth(GetPlayerVehicleID(p),vhealth – PATRIOT_M4_VEHICLE_DAMAGE);
}
else
{
new Float:phealth;
GetPlayerHealth(p,phealth);
SetPlayerHealth(p,phealth – PATRIOT_M4_PLAYER_DAMAGE);
}
PlayerPlaySound(p,1135,0,0,0);
}
}
}
}
}
}
if(count == 0)
{
PlayerInfo[playerid][Firing] = 0;
}
}
else
{
KillTimer(ShootTimer[playerid]);
}
}
//—————–End of Timers—————–//
// //
//——————–Methods——————–//
SavePlayerStats(playerid)
{
if(PlayerInfo[playerid][LoggedIn] == 1)
{
new query[256];
new pstring[256];
mysql_format(SQLConnection,query,sizeof(query),”UPDATE `cnr_users` SET `adminlevel`=’%d’,`ip`=’%s’,`score`=’%d’,`money`=’%d’,`swat`=’%d’ WHERE `id`=’%i'”,PlayerInfo[playerid][AdminLevel],PlayerInfo[playerid][IP],GetPlayerScore(playerid),PlayerInfo[playerid][Money],PlayerInfo[playerid][SWAT],PlayerInfo[playerid][SQLID]);
mysql_query(SQLConnection,query,false);
format(pstring,sizeof(pstring),”[STATS SAVED] %s(%d) – Adminlevel: %d | IP: %s | Score: %d | Money: %d | Swat: %d | ID: %i”,PlayerInfo[playerid][Name],playerid,PlayerInfo[playerid][AdminLevel],PlayerInfo[playerid][IP],GetPlayerScore(playerid),PlayerInfo[playerid][Money],PlayerInfo[playerid][SWAT],PlayerInfo[playerid][SQLID]);
print(pstring);
}
return 1;
}
KickWithMessage(playerid, message[])
{
SendClientMessage(playerid, COLOR_RED, message);
SetTimerEx(“Kicked”, 100, false, “i”, playerid);
}
public Kicked(playerid)
{
Kick(playerid);
}
ResetPlayerVars(playerid)
{
PlayerInfo[playerid][AdminLevel] = 0;
PlayerInfo[playerid][IP] = “255.255.255.255”;
PlayerInfo[playerid][Spawned] = 0;
PlayerInfo[playerid][Team] = 0;
PlayerInfo[playerid][Money] = 0;
PlayerInfo[playerid][LottoNum] = 0;
PlayerInfo[playerid][SWAT] = 0;
PlayerInfo[playerid][SamRec] = 0;
}
ClearChatForPlayer(playerid)
{
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
SendClientMessage(playerid,-1,””);
}
GetVehicleModelFromName(vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i],vname,true) != -1 )
return i + 400;
}
return -1;
}
CheckSWAT(playerid)
{
new answer[4];
if(PlayerInfo[playerid][SWAT] == 1)
{
answer = “Yes”;
return answer;
}
else
{
answer = “No”;
return answer;
}
}
GivePlayerMoneyEx(playerid,amount) //Don’t want any of dem money hackers
{
PlayerInfo[playerid][Money] = PlayerInfo[playerid][Money] + amount;
GivePlayerMoney(playerid,amount);
}
CreateCustomPatriot(type,Float:x,Float:y,Float:z,Float:r)
{
PatriotInfo[PatriotCount+1][vehid] = CreateVehicle(470,x,y,z,r,0,0,120,1);
PatriotCount++;
SetVehicleHealth(PatriotInfo[PatriotCount][vehid],2500);
switch(type)
{
case 0: //SAM
{
PatriotInfo[PatriotCount][ptype] = 0;
PatriotInfo[PatriotCount][object] = CreateObject(18848,x,y,z,0,0,0);
AttachObjectToVehicle(PatriotInfo[PatriotCount][object],PatriotInfo[PatriotCount][vehid], 0.0, -0.5, 0.6, 0.0, 0.0, 0.0);
SetVehicleNumberPlate(PatriotInfo[PatriotCount][vehid],”SAM”);
}
case 1: //Minigun
{
PatriotInfo[PatriotCount][ptype] = 1;
PatriotInfo[PatriotCount][object] = CreateObject(362,x,y,z,0,0,0);
PatriotInfo[PatriotCount][object2] = CreateObject(362,x,y,z,0,0,0);
AttachObjectToVehicle(PatriotInfo[PatriotCount][object],PatriotInfo[PatriotCount][vehid],-0.824999,0.974999,0.824999,0.000000,29.700000,91.799980);
AttachObjectToVehicle(PatriotInfo[PatriotCount][object2],PatriotInfo[PatriotCount][vehid],0.899999,0.974999,0.824999,0.000000,29.700000,91.799980);
SetVehicleNumberPlate(PatriotInfo[PatriotCount][vehid],”MINIGUN”);
}
case 2: //M4
{
PatriotInfo[PatriotCount][ptype] = 2;
PatriotInfo[PatriotCount][object] = CreateObject(356,x,y,z,0,0,0);
PatriotInfo[PatriotCount][object2] = CreateObject(356,x,y,z,0,0,0);
AttachObjectToVehicle(PatriotInfo[PatriotCount][object],PatriotInfo[PatriotCount][vehid],-1.200000,1.200000,0.225000,0.000000,5.400000,91.799980);
AttachObjectToVehicle(PatriotInfo[PatriotCount][object2],PatriotInfo[PatriotCount][vehid],1.200000,1.200000,0.225000,0.000000,5.400000,91.799980);
SetVehicleNumberPlate(PatriotInfo[PatriotCount][vehid],”M4″);
}
}
printf(“[SWAT PATRIOT] SWAT Patriot created. Type: %d | X: %f | Y: %f | Z: %f | R: %f |”,type,x,y,z,r);
}
IsPlayerInAircraft(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
for(new i = 0; i < sizeof(Aircraft); i++)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == Aircraft[i])
{
return true;
}
}
return false;
}
else return false;
}
PatriotRemoveGunFlashes(patriotid)
{
if(IsValidObject(PatriotInfo[patriotid][gunflash1]))
{
DestroyObject(PatriotInfo[patriotid][gunflash1]);
}
if(IsValidObject(PatriotInfo[patriotid][gunflash2]))
{
DestroyObject(PatriotInfo[patriotid][gunflash2]);
}
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) // Thnx random person from SA-MP forums
{
new Float:a;
GetPlayerPos(playerid,x,y,a);
GetPlayerFacingAngle(playerid,a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid),a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
//——————End of Methods——————//
// //
//——————End of Gamemode——————//