Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- dynamicEntrances by KarolisK
- ----------------------------
- 2013-12-22
- */
- #if !defined PRESSED
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #endif
- #if !defined MAX_ENTRANCE_TEXT
- #define MAX_ENTRANCE_TEXT 500
- #endif
- #if !defined MAX_ENTRANCES
- #define MAX_ENTRANCES 100
- #endif
- #if !defined MAX_DRAW_DISTANCE
- #define MAX_DRAW_DISTANCE 25.0
- #endif
- #if !defined OBJECTS_CREATE_DELAY
- #define OBJECTS_CREATE_DELAY 2000
- #endif
- #if !defined KEY_TO_ENTER
- #define KEY_TO_ENTER KEY_SECONDARY_ATTACK
- #endif
- new createdEntrances = 1;
- enum ENTRANCE_DATA
- {
- e_ENTRANCE_ID,
- e_ENTRANCE_TEXT[MAX_ENTRANCE_TEXT],
- Float:e_ENTRANCE_POS_X,
- Float:e_ENTRANCE_POS_Y,
- Float:e_ENTRANCE_POS_Z,
- Float:e_ENTRANCE_EXIT_POS_X,
- Float:e_ENTRANCE_EXIT_POS_Y,
- Float:e_ENTRANCE_EXIT_POS_Z,
- e_INTERIOR,
- Text3D:e_ENTRANCE_LABEL,
- Text3D:e_ENTRANCE_EXIT_LABEL,
- bool:destroyed
- };
- new entrances[ MAX_ENTRANCES ][ ENTRANCE_DATA ];
- stock CreateEntrance( e_entrance_string[], Float:e_entrance_pos_x, Float:e_entrance_pos_y, Float:e_entrance_pos_z, Float:e_entrance_exit_pos_x, Float:e_entrance_exit_pos_y, Float:e_entrance_exit_pos_z, e_interior )
- {
- entrances[createdEntrances][e_ENTRANCE_ID] = createdEntrances;
- format( entrances[createdEntrances][e_ENTRANCE_TEXT], MAX_ENTRANCE_TEXT, e_entrance_string );
- entrances[createdEntrances][e_INTERIOR] = e_interior;
- entrances[createdEntrances][destroyed] = false;
- // iejimas
- entrances[createdEntrances][e_ENTRANCE_POS_X] = e_entrance_pos_x;
- entrances[createdEntrances][e_ENTRANCE_POS_Y] = e_entrance_pos_y;
- entrances[createdEntrances][e_ENTRANCE_POS_Z] = e_entrance_pos_z;
- // isejimas
- entrances[createdEntrances][e_ENTRANCE_EXIT_POS_X] = e_entrance_exit_pos_x;
- entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Y] = e_entrance_exit_pos_y;
- entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Z] = e_entrance_exit_pos_z;
- // 3dlabelis
- entrances[createdEntrances][e_ENTRANCE_LABEL] = Create3DTextLabel(e_entrance_string, 0xFFFFFFFF,e_entrance_pos_x,e_entrance_pos_y, e_entrance_pos_z, MAX_DRAW_DISTANCE, 0);
- entrances[createdEntrances][e_ENTRANCE_EXIT_LABEL]= Create3DTextLabel("Išėjimas", 0xFFFFFFFF,e_entrance_exit_pos_x, e_entrance_exit_pos_y, e_entrance_exit_pos_z, MAX_DRAW_DISTANCE, 0);
- // else
- printf( "[dynamicEntrances]: Iejimas pavadinimu %s sukurtas %f %f %f pozicijoje.",e_entrance_string,e_entrance_pos_x,e_entrance_pos_y, e_entrance_pos_z );
- return entrances[createdEntrances][e_ENTRANCE_ID], createdEntrances++;
- }
- stock entrances_init(playerid, newkeys, oldkeys)
- {
- if (PRESSED( KEY_TO_ENTER ))
- {
- for( new e; e < MAX_ENTRANCES; e++)
- {
- if( !entrances[ e ][ destroyed ] )
- {
- if( IsPlayerInRangeOfPoint( playerid, 2, entrances[createdEntrances][e_ENTRANCE_POS_X],entrances[createdEntrances][e_ENTRANCE_POS_Y],entrances[createdEntrances][e_ENTRANCE_POS_Z] ))
- {
- if( GetPlayerInterior( playerid ) == 0)
- {
- #if defined LOAD_OBJECTS_ON_ENTER
- TogglePlayerControllable( playerid, false );
- GameTextForPlayer(playerid, "Kraunasi objektai...", OBJECTS_CREATE_DELAY, 5);
- SetTimerEx("dynamicLoadObjects", 3000, false, "i", playerid );
- #endif
- SetPlayerPos( playerid, entrances[createdEntrances][e_ENTRANCE_EXIT_POS_X],entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Y],entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Z] );
- SetPlayerInterior( playerid, entrances[createdEntrances][e_INTERIOR] );
- }
- }
- else if( IsPlayerInRangeOfPoint( playerid, 2, entrances[createdEntrances][e_ENTRANCE_EXIT_POS_X],entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Y],entrances[createdEntrances][e_ENTRANCE_EXIT_POS_Z] ) )
- {
- if( GetPlayerInterior( playerid ) == entrances[createdEntrances][e_INTERIOR] )
- {
- #if defined LOAD_OBJECTS_ON_ENTER
- TogglePlayerControllable( playerid, false );
- GameTextForPlayer(playerid, "Kraunasi objektai...", OBJECTS_CREATE_DELAY, 5);
- SetTimerEx("dynamicLoadObjects", 3000, false, "i", playerid );
- #endif
- SetPlayerPos( playerid, entrances[createdEntrances][e_ENTRANCE_POS_X],entrances[createdEntrances][e_ENTRANCE_POS_Y],entrances[createdEntrances][e_ENTRANCE_POS_Z] );
- SetPlayerInterior( playerid, 0 );
- }
- }
- }
- }
- }
- return 1;
- }
- stock DestroyEntrance( entranceid )
- {
- Delete3DTextLabel( entrances[ entranceid ][ e_ENTRANCE_LABEL ] );
- Delete3DTextLabel( entrances[ entranceid ][ e_ENTRANCE_EXIT_LABEL ] );
- entrances[ entranceid ][ destroyed ] = true;
- return printf("[dynamicEntrances]: %i iejimas sunaikintas!", entranceid ), 1;
- }
- stock UpdateEntranceText( entranceid, _text[] )
- {
- Update3DTextLabelText( entrances[ entranceid ][ e_ENTRANCE_LABEL ], 0xFFFFFFFF, _text);
- return printf("[dynamicEntrances]: %i iejimo tekstas atnaujintas!", entranceid ), 1;
- }
- #if defined LOAD_OBJECTS_ON_ENTER
- forward dynamicLoadObjects(playerid);
- public dynamicLoadObjects( playerid )
- {
- TogglePlayerControllable(playerid, true);
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement