Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this file,
- You can obtain one at http://mozilla.org/MPL/2.0/
- Script Author: iPLEOMAX, 2012
- Release: 2, Minor Fixes
- */
- #if defined _ret_included
- #endinput
- #endif
- #define _ret_included
- #include <a_samp>
- #if !defined MAX_RESULT_SIZE
- #define MAX_RESULT_SIZE (128)
- #endif
- #if !defined MAX_TEMPSTR_SIZE
- #define MAX_TEMPSTR_SIZE (1024)
- #endif
- #define ClearString(%0) \
- for(new index = 0; index < sizeof %0; index++) %0[index] = '\0'
- #define RET:%0(%1) forward retf_%0(%1); public retf_%0(%1)
- #define RETF(%0,%1) return format(Parse_Result, sizeof(Parse_Result), %0, %1)
- /*
- native returnf(string[], playerid = INVALID_PLAYER_ID);
- native RETF(const format[], {Float,_}:...);
- */
- new
- Parse_Result [MAX_RESULT_SIZE],
- Return_Temp [MAX_TEMPSTR_SIZE]
- ;
- stock returnf( iString[], playerid = INVALID_PLAYER_ID )
- {
- if(strfind(iString, "#", false) == -1) return false;
- ClearString(Return_Temp);
- new iStart, bool:iCap;
- for ( new iPos = 0, iLen = strlen(iString); iPos < iLen; iPos++ )
- {
- if ( !iCap && iString[iPos] == '#' )
- {
- iStart = iPos;
- iCap = true;
- }
- else if ( iCap && iString[iPos] == '#' )
- {
- iCap = false;
- new Function[64];
- strmid(Function, iString, iStart + 1, iPos);
- strins(Function, "retf_", 0);
- if(playerid != INVALID_PLAYER_ID) CallLocalFunction(Function, "d", playerid);
- else CallLocalFunction(Function, "");
- strcat(Return_Temp, Parse_Result);
- ClearString(Parse_Result);
- }
- else if (iCap) {}
- else InsertToTempString( iString[iPos] );
- }
- format(iString, strlen(Return_Temp) + 1, "%s", Return_Temp);
- return true;
- }
- stock InsertToTempString( character )
- {
- for(new iPos; iPos < sizeof Return_Temp; iPos++)
- {
- if(Return_Temp[iPos] == '\0')
- {
- Return_Temp[iPos] = character;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement