Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <zcmd>
- #include <streamer>
- #include <YSI\y_iterate>
- #include <sscanf2>
- #define Filterscript
- #define MYSQL_HOST "localhost" //IP or Domain of the Mysql Host. DEFAULT:LOCALHOST
- #define MYSQL_USER "root" //The account you made. DEFAULT:ROOT
- #define MYSQL_PASS "" //The password you created for the account. DEFAULT:BLANK
- #define MYSQL_DBNAME "sampdb" //The san andreas database you made.
- #define MYSQL_PORT 3306 //The Mysql Port. DEFAULT:3306
- #define MAX_BRIBE (50) //How many briberies can there be ingame, I set the limit to 50 because i like the number.
- #define BRIBE_USE (120) //How often can the same bribe be used in secconds Default 120 : once in 2 minutes.
- new Iterator: bribes<MAX_BRIBE>;
- new BribeSQLHandle = -1;
- enum E_BRIBE
- {
- // saved
- Float: BribeX,
- Float: BribeY,
- Float: BribeZ,
- Float: BribeA,
- BribeVw,
- Text3D: BribeLabel,
- BribeIcon,
- brid
- };
- new BribeData[MAX_BRIBE][E_BRIBE];
- public OnFilterScriptInit()
- {
- BribeSQLHandle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DBNAME, MYSQL_PASS, MYSQL_PORT);
- mysql_log(LOG_ALL);
- mysql_tquery(BribeSQLHandle, "CREATE TABLE IF NOT EXISTS `bribes` (\
- `ID` int(11) NOT NULL,\
- `PosX` float NOT NULL,\
- `PosY` float NOT NULL,\
- `PosZ` float NOT NULL,\
- `PosA` float NOT NULL\
- `vw` int(11) NOT NULL\
- PRIMARY KEY (`ID`)\
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- if(mysql_errno()) return printf(" [Bribe System] Can't connect to MySQL. (Error #%d)", mysql_errno());
- print("\n--------------------------------------");
- print("---------Bribe System 1.0 By yvoms------");
- print("--------------------------------------\n");
- print(" [Bribe System] Connected to MySQL, loading data...");
- mysql_tquery(BribeSQLHandle, "SELECT * FROM bribe", "LoadBribes");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print(" [Bribe System] Unloaded.");
- mysql_close(BribeSQLHandle);
- return 1;
- }
- forward LoadBribes();
- public LoadBribes()
- {
- new rows = cache_num_rows();
- if(rows)
- {
- new id, label_string[64];
- for(new i; i < rows; i++)
- {
- id = cache_get_field_content_int(i, "ID");
- BribeData[id][BribeX] = cache_get_field_content_float(i, "PosX");
- BribeData[id][BribeY] = cache_get_field_content_float(i, "PosY");
- BribeData[id][BribeZ] = cache_get_field_content_float(i, "PosZ");
- BribeData[id][BribeA] = cache_get_field_content_float(i, "PosA");
- BribeData[id][BribeVw] = cache_get_field_content_int(i,"vw");
- BribeData[id][BribeIcon] = CreateDynamicPickup(1247, 1, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ]);
- format(label_string, sizeof(label_string), "[Bribe %d]", id);
- BribeData[id][BribeLabel] = CreateDynamic3DTextLabel(label_string, 0x1ABC9CFF, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ] + 0.25, 5.0, .testlos = 1);
- Iter_Add(bribes, id);
- }
- }
- printf("[Bribe System] Loaded %d Bribes.", Iter_Count(bribes));
- return 1;
- }
- static DelayTick[MAX_PLAYERS];
- hook OnPlayerPickUpPickup(playerid, pickupid)
- {
- new id;
- if((gettime() - DelayTick[playerid]) < BRIBE_USE) return 1;
- if(pickupid == BribeData[id][brid])
- {
- DelayTick[playerid] = gettime();
- SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) -2);
- SendClientMessage(playerid, 0xFFFFFFAA, "{ABD182}[Notice]:{FAFAFA} Your wanted level has decreased by 2 since your picked up a bribe star!");
- return 1;
- }
- return 1;
- }
- CMD:createbribe(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFAA, "{ff0000}[Error]:{ffffff} Only RCON admins can use this command.");
- new id = Iter_Free(bribes);
- if(id == -1) return SendClientMessage(playerid, 0xFFFFFFAA, "{ff0000}[Error]:{ffffff} MAX_BRIBE reached, check the filterscript.");
- new skin;
- GetPlayerPos(playerid, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ]);
- GetPlayerFacingAngle(playerid, BribeData[id][BribeA]);
- BribeData[id][BribeVw] = GetPlayerVirtualWorld(playerid);
- SetPlayerPos(playerid, BribeData[id][BribeX] + (1.0 * floatsin(-BribeData[id][BribeA], degrees)), BribeData[id][BribeY] + (1.0 * floatcos(-BribeData[id][BribeA], degrees)), BribeData[id][BribeZ]);
- new label_string[64];
- BribeData[id][BribeIcon] = CreateDynamicPickup(1247, 1, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ]);
- format(label_string, sizeof(label_string), "[Bribe %d]", id);
- BribeData[id][BribeLabel] = CreateDynamic3DTextLabel(label_string, 0x1ABC9CFF, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ] + 0.25, 5.0, .testlos = 1);
- new query[144];
- mysql_format(BribeSQLHandle, query, sizeof(query), "INSERT INTO bribes SET ID=%d, PosX='%f', PosY='%f', PosZ='%f', PosA='%f', vw='%d'", id, skin, BribeData[id][BribeX], BribeData[id][BribeY], BribeData[id][BribeZ], BribeData[id][BribeA], BribeData[id][BribeVw]);
- mysql_tquery(BribeSQLHandle, query);
- Iter_Add(bribes, id);
- return 1;
- }
- CMD:removebribe(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFAA, "{ff0000}[Error]:{ffffff} Only RCON admins can use this command.");
- new id;
- if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{ff0000}[Error]:{ffffff} /removebribe [bribe id]");
- if(!Iter_Contains(bribes, id)) return SendClientMessage(playerid, 0xFFFFFFAA, "{ff0000}[Error]:{ffffff} Invalid bribe ID.");
- if(IsValidDynamic3DTextLabel(BribeData[id][BribeLabel])) DestroyDynamic3DTextLabel(BribeData[id][BribeLabel]);
- BribeData[id][BribeLabel] = Text3D: -1;
- DestroyDynamicPickup(BribeData[id][BribeIcon]);
- Iter_Remove(bribes, id);
- new query[48];
- mysql_format(BribeSQLHandle, query, sizeof(query), "DELETE FROM bribes WHERE ID=%d", id);
- mysql_tquery(BribeSQLHandle, query);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement