Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- FilterScript:
- - Dinamicno kreiranje trafika ( MySQL )
- Author:
- - Xalazy(Mungoslav)
- Credits:
- - #XScript2k19
- */
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- #include < a_samp >
- #include < a_mysql >
- #include < Pawn.CMD >
- #include < foreach >
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- #define MYSQL_HOST "127.0.0.1"
- #define MYSQL_USER "root"
- #define MYSQL_PASSWORD ""
- #define MYSQL_DATABASE "trafike_db"
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- #define MAX_TRAFIKA 150
- #define SCM SendClientMessage
- enum tINFO {
- Float:PosX,
- Float:PosY,
- Float:PosZ,
- Float:RotX,
- Float:RotY,
- Float:RotZ,
- trafikaID,
- tID
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- new MySQL:x_sql;
- new TrafikaInfo[ MAX_TRAFIKA ][ tINFO ], edit_Trafika[ MAX_PLAYERS ],
- Iterator:iteratortrafike<MAX_TRAFIKA>;
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) {
- if(response == EDIT_RESPONSE_FINAL) {
- if(edit_Trafika[ playerid ] != -1) {
- new i = edit_Trafika[ playerid ], query[ 250 ];
- TrafikaInfo[ i ][ PosX ] = fX;
- TrafikaInfo[ i ][ PosY ] = fY;
- TrafikaInfo[ i ][ PosZ ] = fZ;
- TrafikaInfo[ i ][ RotX ] = fRotX;
- TrafikaInfo[ i ][ RotY ] = fRotY;
- TrafikaInfo[ i ][ RotZ ] = fRotZ;
- DestroyObject(TrafikaInfo[ i ][ trafikaID ]);
- TrafikaInfo[ i ][ trafikaID ] = CreateObject(1571, fX, fY, fZ, fRotX, fRotY, fRotZ);
- mysql_format(x_sql, query, sizeof query, "INSERT INTO `trafikice` (`PosX`, `PosY`, `PosZ`, `RotX`, `RotY`, `RotZ`) VALUES ('%f', '%f', '%f', '%f', '%f', '%f')", TrafikaInfo[ i ][ PosX ], TrafikaInfo[ i ][ PosY ], TrafikaInfo[ i ][ PosZ ], TrafikaInfo[ i ][ RotX ], TrafikaInfo[ i ][ RotY ], TrafikaInfo[ i ][ RotZ ]);
- mysql_tquery(x_sql, query);
- edit_Trafika[ playerid ] = -1;
- }
- }
- return true;
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- public OnGameModeInit() {
- new MySQLOpt: option_id = mysql_init_options();
- x_sql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id);
- if (x_sql == MYSQL_INVALID_HANDLE || mysql_errno(x_sql) != 0){
- print("< MySQL >: Konekcija je neuspesna !");
- SendRconCommand("exit");
- return true;
- }
- print("< MySQL >: Konekcija je uspesna !");
- kreirajtablu();
- mysql_tquery(x_sql, "SELECT * FROM `trafikice`", "UcitajTrafike", "");
- return true;
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- forward UcitajTrafike();
- public UcitajTrafike() {
- new rows = cache_num_rows();
- if(rows) {
- for(new i; i < rows; i++) {
- new id = Iter_Free(iteratortrafike);
- cache_get_value_name_float(i, "PosX", TrafikaInfo[ id ][ PosX ]);
- cache_get_value_name_float(i, "PosY", TrafikaInfo[ id ][ PosY ]);
- cache_get_value_name_float(i, "PosZ", TrafikaInfo[ id ][ PosZ ]);
- cache_get_value_name_float(i, "RotX", TrafikaInfo[ id ][ RotX ]);
- cache_get_value_name_float(i, "RotY", TrafikaInfo[ id ][ RotY ]);
- cache_get_value_name_float(i, "RotZ", TrafikaInfo[ id ][ RotZ ]);
- TrafikaInfo[ i ][ trafikaID ] = CreateObject(1439, TrafikaInfo[ i ][ PosX ], TrafikaInfo[ i ][ PosY ], TrafikaInfo[ i ][ PosZ ], TrafikaInfo[ i ][ RotX ], TrafikaInfo[ i ][ RotY ], TrafikaInfo[ i ][ RotZ ]);
- Iter_Add(iteratortrafike, id);
- }
- }
- return true;
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- kreirajtablu() {
- mysql_tquery(x_sql, "CREATE TABLE IF NOT EXISTS `trafikice` (`id` int(11) NOT NULL AUTO_INCREMENT,`PosX` float NOT NULL,`PosY` float NOT NULL,`PosZ` float NOT NULL,`RotX` float NOT NULL, `RotY` float NOT NULL, `RotZ` float NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`))");
- return true;
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- CMD:kreirajtrafiku(playerid, params[]) {
- new Float:X, Float:Y, Float:Z, i = Iter_Free(iteratortrafike);
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, "Niste administrator.");
- GetPlayerPos(playerid, X,Y,Z);
- TrafikaInfo[ i ][ trafikaID ] = CreateObject(1571, X, Y, Z, 0.0, 0.0, 0.0);
- EditObject(playerid, TrafikaInfo[ i ][ trafikaID ]);
- edit_Trafika[ playerid ] = i;
- TrafikaInfo[ i ][ tID ] = i;
- SCM(playerid, -1, "< Trafika >: Zapoceli ste kreiranje trafike.");
- return true;
- }
- //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-//
- /*
- ______________________________________________________________________________
- | |
- | K R A J |
- | |
- ------------------------------------------------------------------------------
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement