Last active
August 29, 2015 14:21
-
-
Save TheDutchDev/9491ac92b4e955ff5bcc to your computer and use it in GitHub Desktop.
Teleports.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if !defined S_MAX_TELEPORTS | |
#define S_MAX_TELEPORTS (50) | |
#endif | |
#if !defined S_MAX_TEL_NAME | |
#define S_MAX_TEL_NAME (24) | |
#endif | |
#if !defined S_MAX_CMD_NAME | |
#define S_MAX_CMD_NAME (32) | |
#endif | |
#if !defined ENVLOADED_MSG | |
#define ENVLOADED_MSG ("Environment loaded!") | |
#endif | |
#if !defined ENVLOADING_MSG | |
#define ENVLOADING_MSG ("Loading environment...") | |
#if !defined USE_AUTO_COMMANDS | |
#define USE_AUTO_COMMANDS true | |
#endif | |
#if !defined COLOR_ORANGE | |
#define COLOR_ORANGE (0xFF8800FF) | |
#endif | |
#if !defined strcpy | |
#define strcpy(%0,%1) strcat((%0[0] = EOS,%0), %1) | |
#endif | |
enum S_TEL_DATA | |
{ | |
NAME[ S_MAX_TEL_NAME ], | |
Float: X_POS, | |
Float: Y_POS, | |
Float: Z_POS, | |
Float: ANGLE, | |
INTERIOR, | |
VWORLD, | |
bool: CMD_ENABLED, | |
CMD_NAME[ S_MAX_CMD_NAME ] | |
}; | |
new | |
s_Teleports[ S_MAX_TELEPORTS ][ S_TEL_DATA ]; | |
static | |
s_count = 0; | |
#define GetTeleportName(%0) s_Teleports[%0][NAME] | |
#define GetTeleportInterior(%0) s_Teleports[%0][INTERIOR] | |
#define GetTeleportWorld(%0) s_Teleports[%0][VWORLD] | |
#define GetTeleportAngle(%0) s_Teleports[%0][ANGLE] | |
forward OnPlayerTeleport( playerid, teleportid ); | |
stock CreateTeleport( name[ ], Float:x, Float:y, Float:z, Float:angle, interiorid, worldid, cmdname[ ] = "\0" ) | |
{ | |
if( s_count > S_MAX_TELEPORTS ) | |
return printf( "[EXPLOIT] Teleport limit in teleports.inc has exceeded. please increase S_MAX_TELEPORTS or contact the developer!" ); | |
strcpy( s_Teleports[ s_count ][ NAME ], name, S_MAX_TEL_NAME ); | |
strcpy( s_Teleports[ s_count ][ CMD_NAME ], cmdname, S_MAX_CMD_NAME ); | |
s_Teleports[ s_count ][ CMD_ENABLED ] = ( !strcmp( cmdname, "0", true ) ? false : true ); | |
printf( "%b", s_Teleports[ s_count ][ CMD_ENABLED ] ); | |
s_Teleports[ s_count ][ X_POS ] = x; | |
s_Teleports[ s_count ][ Y_POS ] = y; | |
s_Teleports[ s_count ][ Z_POS ] = z; | |
s_Teleports[ s_count ][ ANGLE ] = angle; | |
s_Teleports[ s_count ][ INTERIOR ] = interiorid; | |
s_Teleports[ s_count ][ VWORLD ] = worldid; | |
s_count++; | |
return ( s_count - 1 ); | |
} | |
stock TeleportPlayer( playerid, telid, bool:allowvehicle = false, bool:loadenv = true ) | |
{ | |
SetPlayerInterior( playerid, s_Teleports[ telid ][ INTERIOR ] ); | |
SetPlayerVirtualWorld( playerid, s_Teleports[ telid ][ VWORLD ] ); | |
if( GetPlayerState( playerid ) == PLAYER_STATE_DRIVER && allowvehicle ) | |
{ | |
new vehicleid = GetPlayerVehicleID( playerid ); | |
SetVehiclePos( vehicleid, s_Teleports[ telid ][ X_POS ], s_Teleports[ telid ][ Y_POS ], s_Teleports[ telid ][ Z_POS ] ); | |
SetVehicleZAngle( vehicleid, s_Teleports[ telid ][ ANGLE ] ); | |
LinkVehicleToInterior( vehicleid, s_Teleports[ telid ][ INTERIOR ] ); | |
SetVehicleVirtualWorld( vehicleid, s_Teleports[ telid ][ VWORLD ] ); | |
} | |
else | |
{ | |
SetPlayerPos( playerid, s_Teleports[ telid ][ X_POS ], s_Teleports[ telid ][ Y_POS ], s_Teleports[ telid ][ Z_POS ] ); | |
SetPlayerFacingAngle( playerid, s_Teleports[ telid ][ ANGLE ] ); | |
} | |
if( loadenv ) | |
{ | |
TogglePlayerControllable( playerid, false ); | |
SetTimerEx( "s_Unfreeze", 2000, false, "i", playerid ); | |
GameTextForPlayer( playerid, ENVLOADING_MSG, 2000, 3 ); | |
} | |
CallLocalFunction( "OnPlayerTeleport", "ii", playerid, telid ); | |
return 1; | |
} | |
forward s_Unfreeze( playerid ); | |
public s_Unfreeze( playerid ) | |
{ | |
GameTextForPlayer( playerid, ENVLOADED_MSG, 1000, 3 ); | |
TogglePlayerControllable( playerid, true ); | |
return 1; | |
} | |
stock ReturnTeleportCommands( ) | |
{ | |
new result[ 128 ]; | |
for( new i = 0; i < s_count; i++ ) | |
{ | |
strcat( result, s_Teleports[ i ][ CMD_NAME ] ); | |
strcat( result, " " ); | |
} | |
return result; | |
} | |
#if USE_AUTO_COMMANDS == true | |
// Thanks, Lordzy! | |
public OnPlayerCommandPerformed(playerid, cmdtext[], success) | |
{ | |
if( !success ) | |
{ | |
for( new i = 0; i < s_count; i++) | |
{ | |
if( !s_Teleports[ i ][ CMD_ENABLED ] ) | |
continue; | |
if(!strcmp( cmdtext, s_Teleports[ i ][ CMD_NAME ], true, strlen( s_Teleports[ i ][ CMD_NAME ] ) ) ) | |
{ | |
TeleportPlayer( playerid, i ); | |
return 1; | |
} | |
} | |
return 0; | |
} | |
return 1; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment