Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dynamic Entrance System
- By Raimis_[R]
- Deutsche Übersetzung und Edierung by Inf3rnus
- */
- #define FILTERSCRIPT
- /* Includes */
- #include <a_samp>
- #include "../include/a_mysql.inc"
- #include "../include/sscanf2.inc"
- #include "../include/zcmd.inc"
- /* Die MySQL Login Daten */
- #define MySQL_HOST "localhost"
- #define MySQL_USER "root"
- #define MySQL_DB "rpg"
- #define MySQL_PASS ""
- #define MAX_ENTRANCES (100)
- #define MAX_ENTRANCE_NAME (25)
- #define void%0(%1)\
- forward%0(%1); public%0(%1)
- #define function%0(%1)\
- stock%0(%1)
- #define forEx(%0,%1)\
- for(new %0; %0 != %1; %0++)
- #define PRESSED(%0)\
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- enum items
- {
- ID,
- Name[MAX_ENTRANCE_NAME],
- Float:Enter[3],
- Float:Exit[3],
- Interior,
- VirtualW
- }
- new eSystem[MAX_ENTRANCES][items];
- new Text3D:EnterLabel[MAX_ENTRANCES];
- public OnFilterScriptInit()
- {
- CreateMySQLConnection(MySQL_HOST, MySQL_USER, MySQL_DB, MySQL_PASS);
- mysql_query("SELECT * FROM `entrances`");
- mysql_store_result();
- new query[200], string[66], Count = 1;
- while(mysql_fetch_row(query))
- {
- sscanf(query,"e<p<|>is[25]ffffffii>",eSystem[Count]);
- format(string,sizeof(string),"%s\nBenutze die Taste [ENTER] um es zu Betreten!", eSystem[Count][Name]);
- EnterLabel[Count] = Create3DTextLabel(string, -1, eSystem[Count][Enter][0], eSystem[Count][Enter][1], eSystem[Count][Enter][2], 100.0, 0, 0);
- Count++;
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("INFO: DES System UnLoaded!");
- mysql_close();
- print("INFO: MySQL Connection closed!");
- return 1;
- }
- command(create, playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) return 0;
- new pName[MAX_ENTRANCE_NAME], pInterior, query[200];
- if (sscanf(params,"s[25]i", pName, pInterior))
- {
- return SendClientMessage(playerid, -1, "* Benutze: /create [Name des Eingangs] [Interior ID]");
- }
- if (strlen(pName) > MAX_ENTRANCE_NAME)
- {
- return SendClientMessage(playerid, -1, "* Der Name des Eingangs kann nicht länger als 25 Simbole lang sein!");
- }
- new Float:Player[3];
- GetPlayerPos(playerid, Player[0], Player[1], Player[2]);
- mysql_query("SELECT MAX(ID) FROM `entrances`");
- mysql_store_result();
- new sqlid[10];
- mysql_fetch_row_format(sqlid,"|");
- printf("INFO: Last ID: %s", sqlid);
- new SQLID = strval(sqlid);
- SQLID++;
- eSystem[SQLID][ID] = SQLID;
- eSystem[SQLID][Name] = pName;
- eSystem[SQLID][Enter][0] = Player[0];
- eSystem[SQLID][Enter][1] = Player[1];
- eSystem[SQLID][Enter][2] = Player[2];
- eSystem[SQLID][VirtualW] = SQLID;
- format(query,sizeof(query),"INSERT INTO `entrances` (`ID`,`Name`,`X`,`Y`,`Z`,`VirtualW`) VALUES ('%i','%s','%f','%f','%f','%i')",
- eSystem[SQLID][ID], eSystem[SQLID][Name], eSystem[SQLID][Enter][0], eSystem[SQLID][Enter][1], eSystem[SQLID][Enter][2], eSystem[SQLID][VirtualW]);
- mysql_query(query);
- new string[66];
- format(string,sizeof(string),"%s\nBenutze die Taste [ENTER] um es zu Betreten!", eSystem[SQLID][Name]);
- EnterLabel[SQLID] = Create3DTextLabel(string, -1, eSystem[SQLID][Enter][0], eSystem[SQLID][Enter][1], eSystem[SQLID][Enter][2], 50.0, 0, 1);
- UpdateExitCordinates(SQLID,pInterior);
- mysql_free_result();
- return 1;
- }
- function UpdateExitCordinates(eID, eInterior)
- {
- switch(eInterior)
- {
- case 1: // LV Gym
- {
- eSystem[eID][Interior] = 7;
- eSystem[eID][Exit][0] = 773.579956;
- eSystem[eID][Exit][1] = -77.096694;
- eSystem[eID][Exit][2] = 1000.655029;
- }
- case 2: // Car school
- {
- eSystem[eID][Interior] = 3;
- eSystem[eID][Exit][0] = -2029.798339;
- eSystem[eID][Exit][1] = -106.675910;
- eSystem[eID][Exit][2] = 1035.171875;
- }
- case 3: // Bike school
- {
- eSystem[eID][Interior] = 3;
- eSystem[eID][Exit][0] = 1494.325195;
- eSystem[eID][Exit][1] = 1304.942871;
- eSystem[eID][Exit][2] = 1093.289062;
- }
- case 4: // LS Police HQ
- {
- eSystem[eID][Interior] = 6;
- eSystem[eID][Exit][0] = 246.783996;
- eSystem[eID][Exit][1] = 63.900199;
- eSystem[eID][Exit][2] = 1003.640625;
- }
- case 5: // Zero's RC Shop
- {
- eSystem[eID][Interior] = 6;
- eSystem[eID][Exit][0] = -2240.468505;
- eSystem[eID][Exit][1] = 137.060440;
- eSystem[eID][Exit][2] = 1035.414062;
- }
- case 6: // Ammunation 1
- {
- eSystem[eID][Interior] = 1;
- eSystem[eID][Exit][0] = 286.148986;
- eSystem[eID][Exit][1] = -40.644397;
- eSystem[eID][Exit][2] = 1001.515625;
- }
- case 7: // 24/7 1
- {
- eSystem[eID][Interior] = 17;
- eSystem[eID][Exit][0] = -25.884498;
- eSystem[eID][Exit][1] = -185.868988;
- eSystem[eID][Exit][2] = 1003.546875;
- }
- case 8: // Jefferson motel
- {
- eSystem[eID][Interior] = 15;
- eSystem[eID][Exit][0] = 2215.454833;
- eSystem[eID][Exit][1] = -1147.475585;
- eSystem[eID][Exit][2] = 1025.796875;
- }
- case 9: // Binco
- {
- eSystem[eID][Interior] = 15;
- eSystem[eID][Exit][0] = 207.737991;
- eSystem[eID][Exit][1] = -109.019996;
- eSystem[eID][Exit][2] = 1005.132812;
- }
- case 10: // Club
- {
- eSystem[eID][Interior] = 17;
- eSystem[eID][Exit][0] = 493.390991;
- eSystem[eID][Exit][1] = -22.722799;
- eSystem[eID][Exit][2] = 1000.679687;
- }
- default: // Bar
- {
- eSystem[eID][Interior] = 11;
- eSystem[eID][Exit][0] = 501.980987;
- eSystem[eID][Exit][1] = -69.150199;
- eSystem[eID][Exit][2] = 998.757812;
- }
- }
- new query[200];
- format(query,sizeof(query),"UPDATE `entrances` SET `exitX` = '%f', `exitY` = '%f', `exitZ` = '%f', `Interior` = '%i' WHERE `ID` = '%i'",
- eSystem[eID][Exit][0], eSystem[eID][Exit][1], eSystem[eID][Exit][2], eSystem[eID][Interior], eID);
- mysql_query(query);
- }
- function CreateMySQLConnection(host[], user[], db[], pass[])
- {
- mysql_connect(host, user, db, pass);
- if (mysql_ping() >= 1)
- {
- print("INFO: Connected To MySQL!");
- }
- else
- {
- print("INFO: Can't Connect To MySQL!");
- }
- }
- void OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (PRESSED(KEY_SECONDARY_ATTACK))
- {
- forEx(i, MAX_ENTRANCES)
- {
- if (IsPlayerInRangeOfPoint(playerid, 2, eSystem[i][Enter][0], eSystem[i][Enter][1], eSystem[i][Enter][2]))
- {
- SetPlayerVirtualWorld(playerid, eSystem[i][VirtualW]);
- SetPlayerInterior(playerid, eSystem[i][Interior]);
- SetPlayerPos(playerid, eSystem[i][Exit][0], eSystem[i][Exit][1], eSystem[i][Exit][2]);
- SetPVarInt(playerid, "entranceID", i); // Need for exit
- break; // Stoping loop
- }
- }
- if (IsPlayerInRangeOfPoint(playerid, 2, eSystem[GetPVarInt(playerid,"entranceID")][Exit][0], eSystem[GetPVarInt(playerid,"entranceID")][Exit][1], eSystem[GetPVarInt(playerid,"entranceID")][Exit][2]))
- {
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, eSystem[GetPVarInt(playerid,"entranceID")][Enter][0], eSystem[GetPVarInt(playerid,"entranceID")][Enter][1], eSystem[GetPVarInt(playerid,"entranceID")][Enter][2]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement