Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "amxxmodule.h"
- static cell AMX_NATIVE_CALL Patch_MapName( AMX * pAmx, cell * pParameters ) {
- char * pMapName = ( char * ) malloc( 128 );
- if( !pMapName ) {
- MF_LogError( pAmx, AMX_ERR_NATIVE, "Something went bad! Unable to allocate a new memory block!" );
- return 0;
- }
- int Length = 0;
- char * pName = ( char * ) MF_GetAmxString( pAmx, pParameters[ 1 ], 0, &Length );
- if( Length < 1 || Length > 128 ) {
- MF_LogError( pAmx, AMX_ERR_NATIVE, "The map name length is null or too long!" );
- free( pMapName );
- return 0;
- }
- sprintf( pMapName, "%s", pName );
- /* Allows any pointer to be converted into any other pointer type! */
- int Address = reinterpret_cast < int > ( gpGlobals -> pStringBase + gpGlobals -> mapname );
- for( int i = 0; i <= Length; i++ )
- *( unsigned char * ) ( Address + i ) = pMapName[ i ];
- free( pMapName );
- return 1;
- }
- AMX_NATIVE_INFO MapPatcherExports[ ] = {
- { "Patch_MapName", Patch_MapName },
- { NULL, NULL }
- };
- void OnAmxxAttach( void ) {
- MF_AddNatives( MapPatcherExports );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement