Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < YSI\y_iterate >
- #define MAX_ATMS ( 500 )
- #define INVALID_ATM_ID ( -1 )
- new Iterator: Atms< MAX_ATMS >;
- enum ATM
- {
- Float: atm_X,
- Float: atm_Y,
- Float: atm_Z,
- AtmObject,
- bool:Save
- }
- new AtmInfo[ MAX_ATMS ] [ ATM ];
- forward LoadATMS();
- public LoadATMS()
- {
- new rows = cache_num_rows( );
- if( rows )
- {
- new id, loaded;
- while( loaded < rows )
- {
- id = cache_get_field_content_int( loaded, "ID" );
- AtmInfo [ id ] [ atm_X ] = cache_get_field_content_float( loaded, "atm_X" );
- AtmInfo [ id ] [ atm_Y ] = cache_get_field_content_float( loaded, "atm_Y" );
- AtmInfo [ id ] [ atm_Z ] = cache_get_field_content_float( loaded, "atm_Z" );
- AtmInfo[ id ] [ AtmObject ] = CreateObject( 19324, AtmInfo [ id ] [ atm_X ], AtmInfo [ id ] [ atm_Y ], AtmInfo [ id ] [ atm_Z ], 0, 0, 0, 50 );
- AtmInfo[ id ] [ Save ] = true;
- Iter_Add( Atms, id );
- loaded ++;
- }
- printf( "Loaded %d ATMs.", loaded );
- }
- return 1;
- }
- CMD:createatm( playerid, params[] )
- {
- new id = Iter_Free( Atms ), Float: x, Float: y, Float: z, query[500];
- if( id == -1 ) return SendClientMessage(playerid, -1, "MAX ATMS has reached");
- GetPlayerPos( playerid, x, y, z );
- AtmInfo[ id ] [ AtmObject ] = CreateObject( 19324, x, y, z, 0, 0, 0, 50 );
- AtmInfo[ id ] [ Save ] = true;
- mysql_format( sqlGameConnection, query, sizeof( query ), "INSERT INTO `atm` SET `ID`='%d', `atm_X`='%f', `atm_Y`='%f', `atm_Z`='%f'", id, x, y, z );
- mysql_tquery( sqlGameConnection, query, "", "" );
- Iter_Add(Atms, id);
- return 1;
- }
- CMD:deleteatm( playerid, params[] )
- {
- new id, query[100];
- if( sscanf( params, "i", id ) ) return SendClientMessage( playerid, -1, "Usage: /deleteatm <ID>" );
- if( !Iter_Contains(Atms, id ) ) return SendClientMessage( playerid, -1, "The ATM ID you entered does not exist!" );
- DestroyObject( AtmInfo[ id ] [ AtmObject ] );
- AtmInfo [ id ] [ atm_X ] = 0;
- AtmInfo [ id ] [ atm_Y ] = 0;
- AtmInfo [ id ] [ atm_Z ] = 0;
- Iter_Remove( Atms, id );
- mysql_format( sqlGameConnection, query, sizeof( query ), "DELETE FROM `atm` WHERE `ID`='%d'", id);
- mysql_tquery( sqlGameConnection, query, "", "" );
- SendClientMessage( playerid, -1, "ATM deleted" );
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement