Advertisement
Guest User

Untitled

a guest
Jul 25th, 2010
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.56 KB | None | 0 0
  1. /*
  2.     @title GVars (Just like PVars)
  3.     @author Carlton
  4.     @copyright 2010
  5.     @description
  6.         Similar like PVars, these are global variables.
  7.  
  8.     - www.volt-host.com
  9.     - www.epic-missions.com
  10. */
  11. //==========================================
  12. #define MAXIMUM_VARIABLES 1000
  13. #define MAXIMUM_CHARACTERS 10
  14. #define CASE_SENSITIVITY true
  15. //==========================================
  16. enum GV_D {
  17.     G_Name[MAXIMUM_CHARACTERS],
  18.     G_Int_Value,
  19.     Float:G_Float_Value,
  20.     G_String_Value[256]
  21. }
  22. new
  23.     G_VAR_DATA[MAXIMUM_VARIABLES][GV_D],
  24.     G_VAR_ID;
  25. //==========================================
  26. stock SetGVarString(varName[], value[]) {
  27.     strmid(G_VAR_DATA[G_VAR_ID][G_Name], varName, 0, strlen(varName), 255);
  28.     strmid(G_VAR_DATA[G_VAR_ID][G_String_Value], value, 0, strlen(value), 255);
  29.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ) {
  30.         if(strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  31.             G_VAR_ID ++;
  32.             break;
  33.         }
  34.     }
  35.     return G_VAR_ID;
  36. }
  37.  
  38. stock GetGVarString(varName[]) {
  39.     new ReturnID[] = "NULL";
  40.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ){
  41.         if(!strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  42.             strmid(ReturnID, G_VAR_DATA[i][G_String_Value], 0, strlen(G_VAR_DATA[i][G_String_Value]), 255);
  43.             break;
  44.         }
  45.     }
  46.     return ReturnID;
  47. }
  48.  
  49. stock SetGVarInt(varName[], value) {
  50.     strmid(G_VAR_DATA[G_VAR_ID][G_Name], varName, 0, strlen(varName), 255);
  51.     G_VAR_DATA[G_VAR_ID][G_Int_Value] = value;
  52.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ) {
  53.         if(strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  54.             G_VAR_ID ++;
  55.             break;
  56.         }
  57.     }
  58.     return G_VAR_ID;
  59. }
  60.  
  61. stock GetGVarInt(varName[]) {
  62.     new ReturnID = -1;
  63.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ){
  64.         if(!strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  65.             ReturnID = G_VAR_DATA[i][G_Int_Value];
  66.             break;
  67.         }
  68.     }
  69.     return ReturnID;
  70. }
  71.  
  72. stock SetGVarFloat(varName[], Float:value) {
  73.     strmid(G_VAR_DATA[G_VAR_ID][G_Name], varName, 0, strlen(varName), 255);
  74.     G_VAR_DATA[G_VAR_ID][G_Float_Value] = value;
  75.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ) {
  76.         if(strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  77.             G_VAR_ID ++;
  78.             break;
  79.         }
  80.     }
  81.     return G_VAR_ID;
  82. }
  83.  
  84. stock Float:GetGVarFloat(varName[]) {
  85.     new Float:ReturnID = -1;
  86.     for(new i = 0; i < MAXIMUM_VARIABLES; i++ ){
  87.         if(!strcmp(G_VAR_DATA[i][G_Name], varName, CASE_SENSITIVITY)) {
  88.             ReturnID = G_VAR_DATA[i][G_Float_Value];
  89.             break;
  90.         }
  91.     }
  92.     return ReturnID;
  93. }
  94.  
  95. stock CountGVars() return G_VAR_ID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement