Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <zcmd>
- #include <sscanf2>
- #include <mSelection>
- #define COLOR_WHITE (0xffffffFF)
- #define COLOR_RED (0xdb1a1aFF)
- #define COLOR_BLUE (0x2265d8FF)
- #define COLOR_YELLOW (0xf6ff00FF)
- #define SCM SendClientMessage
- #define function:%0(%1) forward %0(%1); public %0(%1)
- #define SCMex SendClientMessageEx
- //Dialogs:
- #define DIALOG_REGISTER (0)
- #define DIALOG_LOGIN (1)
- //Database establisher:
- new ourConnection;
- #define SCRIPT_VERSION "Script Adventure 1.0.1.1"
- //================MySQL Connection:=========================
- #define SQL_HOSTNAME "{Fill in}"
- #define SQL_USERNAME "{Fill in}"
- #define SQL_DATABASE "{Fill in}"
- #define SQL_PASSWORD "{Fill in}"
- //==========================================================
- enum P_ACCOUNT_DATA
- {
- pDBID,
- pAccName[60],
- pSkin,
- bool:pLoggedin,
- pAdmin
- }
- new PlayerInfo[MAX_PLAYERS][P_ACCOUNT_DATA];
- new playerLogin[MAX_PLAYERS];
- new joinskin = mS_INVALID_LISTID;
- static stock g_arrVehicleNames[][] = {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster",
- "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
- "Esperanto", "Taxi", "Washington", "Bobcat", "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", "ZR-350", "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", "Cropduster", "Stunt", "Tanker", "Roadtrain",
- "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck",
- "Fortune", "Cadrona", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
- "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
- "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
- "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
- "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30",
- "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
- "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "LSPD Cruiser", "SFPD Cruiser", "LVPD Cruiser",
- "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
- "Boxville", "Tiller", "Utility Trailer"
- };
- main()
- {
- print("\n-------------------------------------");
- print("This is the sick script we are making");
- print("---------------------------------------\n");
- }
- public OnGameModeInit()
- {
- ourConnection = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD);
- SetGameModeText(SCRIPT_VERSION);
- if(mysql_errno() != 0)
- printf ("[DATABASE]: Connection failed to '%s'...", SQL_DATABASE);
- else printf ("[DATABASE]: Connection established to '%s'...", SQL_DATABASE);
- joinskin = LoadModelSelectionMenu("skins.txt");
- return 1;
- }
- public OnGameModeExit()
- {
- mysql_close(ourConnection);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- if(PlayerInfo[playerid][pLoggedin] == false)
- {
- SetSpawnInfo( playerid, 0, 0, 563.3157, 3315.2559, 0, 269.15, 0, 0, 0, 0, 0, 0 );
- TogglePlayerSpectating(playerid, true);
- TogglePlayerSpectating(playerid, false);
- SetPlayerCamera(playerid);
- return 1;
- }
- SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 2098.5088,1159.1156,11.6484, 65.2418, 0, 0, 0, 0, 0, 0 );
- SpawnPlayer(playerid);
- return 0;
- }
- public OnPlayerConnect(playerid)
- {
- SetPlayerCamera(playerid);
- ResetPlayer(playerid);
- new existCheck[248];
- mysql_format(ourConnection, existCheck, sizeof(existCheck), "SELECT * FROM accounts WHERE acc_name = '%e'", ReturnName(playerid));
- mysql_tquery(ourConnection, existCheck, "LogPlayerIn", "i", playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- // NEW
- public OnPlayerModelSelection(playerid, response, listid, modelid)
- {
- if(listid == joinskin)
- {
- if(!response)
- return ShowModelSelectionMenu(playerid, joinskin, "Pick A Skin");
- SetCameraBehindPlayer(playerid);
- SetPlayerSkin(playerid, modelid);
- PlayerInfo[playerid][pSkin] = modelid;
- SetSpawnInfo( playerid, 0, modelid, 2098.5088,1159.1156,11.6484, 65.2418, 0, 0, 0, 0, 0, 0 );
- SpawnPlayer(playerid);
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch (dialogid)
- {
- case DIALOG_REGISTER:
- {
- if(!response)
- {
- SendClientMessage(playerid, COLOR_RED, "You were kicked for not registering.");
- return KickEx(playerid);
- }
- new insert[256];
- if(strlen(inputtext) > 128 || strlen(inputtext) < 3)
- return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to Cubie's Scripting Adventure", "SERVER: You have can now register!\n\nYour password needs to be greater than 3 and less than 128 characters.\nTIP: Please report all bugs that you\nmay have found to development.\n\n Enter Your Password:", "Login", "Cancel");
- mysql_format(ourConnection, insert, sizeof(insert), "INSERT INTO accounts (acc_name, acc_pass, register_ip, register_date) VALUES('%e', sha1('%e'), '%e', '%e')", ReturnName(playerid), inputtext, ReturnIP(playerid), ReturnDate());
- mysql_tquery(ourConnection, insert, "OnPlayerRegister", "i", playerid);
- }
- case DIALOG_LOGIN:
- {
- if (!response)
- {
- SendClientMessage(playerid, COLOR_RED, "You were kicked for not logging in.");
- return KickEx(playerid);
- }
- new continueCheck[211];
- mysql_format(ourConnection, continueCheck, sizeof(continueCheck), "SELECT acc_dbid FROM accounts WHERE acc_name = '%e' AND acc_pass = sha1('%e') LIMIT 1",
- ReturnName(playerid), inputtext);
- mysql_tquery(ourConnection, continueCheck, "LoggingIn", "i", playerid);
- return 1;
- }
- }
- return 1;
- }
- // NEW
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- // Commands
- CMD:makeadmin(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
- {
- new playerb, adminlvl, insert[128];
- if(sscanf(params, "ui", playerb, adminlvl))
- return SCM(playerid, COLOR_RED, "Usage: /makeadmin [playerid/name] [level 1-2]");
- if(adminlvl < 0 || adminlvl > 2)
- return SCM(playerid, COLOR_RED, "Invalid Admin level");
- SCMex(playerid, COLOR_YELLOW, "You've just made: %s admin level: %i", ReturnName(playerb), adminlvl);
- SCMex(playerb, COLOR_YELLOW, "You've just been made admin level: %i by: %s", adminlvl, ReturnName(playerid));
- PlayerInfo[playerb][pAdmin] = adminlvl;
- mysql_format(ourConnection, insert, sizeof(insert), "UPDATE accounts SET Admin = %i WHERE acc_dbid = %i", adminlvl, PlayerInfo[playerb][pDBID]);
- mysql_tquery(ourConnection, insert);
- }
- else return SCM(playerid, COLOR_RED, "You are not allowed to use this command");
- return 1;
- }
- CMD:jetpack(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 1)
- return SCM(playerid, COLOR_RED, "You are not allowed to use this command");
- SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
- return 1;
- }
- CMD:kick(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 1)
- return SCM(playerid, COLOR_RED, "You are not allowed to use this command");
- new playerb;
- if(sscanf(params, "u", playerb))
- return SCM(playerid, COLOR_RED, "Usage: /kick [playerid/name]");
- SCMex(playerid, COLOR_YELLOW, "You've just kicked: %s", ReturnName(playerb));
- SCMex(playerb, COLOR_YELLOW, "You've just been kicked by: %s", ReturnName(playerid));
- KickEx(playerb);
- return 1;
- }
- CMD:kill(playerid, params[])
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- CMD:skin(playerid, params[])
- {
- new skinid;
- if(sscanf(params, "i", skinid))
- return SCM(playerid, COLOR_RED, "Usage: /skin [ID]");
- SetPlayerSkin(playerid, skinid);
- PlayerInfo[playerid][pSkin] = skinid;
- return 1;
- }
- CMD:weapon(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 1)
- return SCM(playerid, COLOR_RED, "You are not allowed to use this command");
- new weaponid, ammo;
- if(sscanf(params, "ii", weaponid, ammo))
- return SCM(playerid, COLOR_RED, "Usage: /weapon [ID], [AMMO]");
- if(weaponid < 1 || weaponid > 46 || weaponid == 18)
- return SCM(playerid, COLOR_RED, "You have specified a invalid weapon");
- if(ammo < 1)
- return SCM(playerid, COLOR_RED, "You have specified invalid ammo amount");
- GivePlayerWeapon(playerid, weaponid, ammo);
- SCM(playerid, COLOR_YELLOW, "Enjoy your Weapon, prick");
- return 1;
- }
- CMD:gotols(playerid, params[])
- {
- SetPlayerPos(playerid, 1519.6636, -1679.0535, 12.8015);
- return 1;
- }
- // Stock Values
- stock ReturnName(playerid, underScore = 1)
- {
- new playersName[MAX_PLAYER_NAME + 2];
- GetPlayerName(playerid, playersName, sizeof(playersName));
- if(!underScore)
- {
- {
- for(new i = 0, j = strlen(playersName); i < j; i ++)
- {
- if(playersName[i] == '_')
- {
- playersName[i] = ' ';
- }
- }
- }
- }
- return playersName;
- }
- stock ReturnIP(playerid)
- {
- new
- ipAddress[20];
- GetPlayerIp(playerid, ipAddress, sizeof(ipAddress));
- return ipAddress;
- }
- stock ReturnDate()
- {
- new sendString[90], MonthStr[40], month, day, year;
- new hour, minute, second;
- gettime(hour, minute, second);
- getdate(year, month, day);
- switch(month)
- {
- case 1: MonthStr = "January";
- case 2: MonthStr = "February";
- case 3: MonthStr = "March";
- case 4: MonthStr = "April";
- case 5: MonthStr = "May";
- case 6: MonthStr = "June";
- case 7: MonthStr = "July";
- case 8: MonthStr = "August";
- case 9: MonthStr = "September";
- case 10: MonthStr = "October";
- case 11: MonthStr = "November";
- case 12: MonthStr = "December";
- }
- format(sendString, 90, "%s %d, %d %02d:%02d:%02d", MonthStr, day, year, hour, minute, second);
- return sendString;
- }
- stock KickEx(playerid)
- {
- return SetTimerEx("KickTimer", 100, false, "i", playerid);
- }
- stock SendClientMessageEx(playerid, color, const str[], {Float,_}:...)
- {
- static
- args,
- start,
- end,
- string[156]
- ;
- #emit LOAD.S.pri 8
- #emit STOR.pri args
- if (args > 12)
- {
- #emit ADDR.pri str
- #emit STOR.pri start
- for (end = start + (args - 12); end > start; end -= 4)
- {
- #emit LREF.pri end
- #emit PUSH.pri
- }
- #emit PUSH.S str
- #emit PUSH.C 156
- #emit PUSH.C string
- #emit PUSH.C args
- #emit SYSREQ.C format
- SendClientMessage(playerid, color, string);
- #emit LCTRL 5
- #emit SCTRL 4
- #emit RETN
- }
- return SendClientMessage(playerid, color, str);
- }
- stock ReturnVehicleName(vehicleid)
- {
- new
- model = GetVehicleModel(vehicleid),
- name[32] = "None";
- if (model < 400 || model > 611)
- return name;
- format(name, sizeof(name), g_arrVehicleNames[model - 400]);
- return name;
- }
- function:LogPlayerIn(playerid)
- {
- new rows, fields;
- cache_get_data(rows, fields, ourConnection);
- if(!rows)
- {
- for(new i = 0; i < 3; i ++) { SendClientMessage(playerid, -1, " "); }
- SendClientMessageEx(playerid, COLOR_YELLOW, "The user (%s) you're connected with is not a registered.", ReturnName(playerid));
- SendClientMessage(playerid, -1, "You need to register to continue.");
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to Cubie's Scripting Adventure", "SERVER: You can now register!\nTIP: Please report all bugs that you\nmay have found to development.\n\n Enter Your Password:", "Register", "Cancel");
- return 1;
- }
- SendClientMessageEx(playerid, COLOR_YELLOW, "Welcome to Cubie's Scripting Adventure, %s {FFFFFF}["SCRIPT_VERSION"]", ReturnName(playerid));
- return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to Cubie's Scripting Adventure", "SERVER: You van now login!\nTIP: Please report all bugs that you\nmay have found to development.\n\n Enter Your Password:", "Login", "Cancel");
- }
- function:OnPlayerRegister(playerid)
- {
- PlayerInfo[playerid][pDBID] = cache_insert_id();
- format(PlayerInfo[playerid][pAccName], 32, "%s", ReturnName(playerid));
- new thread[128];
- mysql_format(ourConnection, thread, sizeof(thread), "SELECT * FROM accounts WHERE acc_name = '%e'", ReturnName(playerid));
- mysql_tquery(ourConnection, thread, "Query_LoadAccount", "i", playerid);
- PlayerInfo[playerid][pLoggedin] = true;
- ShowModelSelectionMenu(playerid, joinskin, "Pick A Skin");
- }
- function:LoggingIn(playerid)
- {
- if(!cache_num_rows())
- {
- playerLogin[playerid]++;
- if(playerLogin[playerid] == 3)
- {
- SendClientMessage(playerid, COLOR_RED, "[SERVER]: You were kicked for bad password attempts.");
- return KickEx(playerid);
- }
- return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to Cubie Emergency Roleplay", "You entered the wrong password!\n\nSERVER: You can now login!\nTIP: Please report all bugs that you\nmay have found to development.\n\n Enter Your Password:", "Login", "Cancel");
- }
- new thread[128];
- mysql_format(ourConnection, thread, sizeof(thread), "SELECT * FROM accounts WHERE acc_name = '%e'", ReturnName(playerid));
- mysql_tquery(ourConnection, thread, "Query_LoadAccount", "i", playerid);
- format(PlayerInfo[playerid][pAccName], 32, "%s", ReturnName(playerid));
- PlayerInfo[playerid][pLoggedin] = true;
- ShowModelSelectionMenu(playerid, joinskin, "Pick A Skin");
- return 1;
- }
- function:Query_LoadAccount(playerid)
- {
- PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin", ourConnection);
- PlayerInfo[playerid][pDBID] = cache_get_field_content_int(0, "acc_dbid", ourConnection);
- return 1;
- }
- function:ResetPlayer(playerid)
- {
- playerLogin[playerid] = 0;
- PlayerInfo[playerid][pDBID] = 0;
- PlayerInfo[playerid][pLoggedin] = false;
- PlayerInfo[playerid][pSkin] = 0;
- PlayerInfo[playerid][pAdmin] = 0;
- return 1;
- }
- function:SetPlayerCamera(playerid)
- {
- new rand = random(3);
- switch(rand)
- {
- case 0:
- {
- SetPlayerCameraPos(playerid, 2019.1145, 1202.9185, 42.3246);
- SetPlayerCameraLookAt(playerid, 2019.9889, 1202.4272, 42.2945);
- }
- case 1:
- {
- SetPlayerCameraPos(playerid, 1701.8396, -1572.9250, 26.6298);
- SetPlayerCameraLookAt(playerid, 1701.2588, -1572.1072, 27.1848);
- }
- case 2:
- {
- SetPlayerCameraPos(playerid, -2619.1006, 2202.6091, 49.9144);
- SetPlayerCameraLookAt(playerid, -2619.2512, 2201.6155, 50.1043);
- }
- }
- return 1;
- }
- function:KickTimer(playerid) { return Kick(playerid); }
Advertisement
Add Comment
Please, Sign In to add comment