Advertisement
DraKiNs

[INC] GVars System

Aug 22nd, 2011
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.02 KB | None | 0 0
  1. /*
  2.  *       GVars System
  3.  * Variables per Name in Pawn
  4.  * Author: Bruno da Silva
  5.  * Site: www.ips-team.blogspot.com
  6.  * Date: 19:08 21/08/2011
  7.  * (C) Copyright [iPs]TeaM
  8.  *
  9. */
  10.  
  11.  
  12. enum gVars
  13. {
  14.     gVarName[32],
  15.     gVarValue[128]
  16. };
  17.  
  18. new
  19.     gVarData[100][gVars],
  20.     maxGVars = 0,
  21.     bool:encontrado = false
  22. ;
  23.  
  24. SetGVarString(varName[], valueVar[128])
  25. {
  26.     for(new i = 0; i != maxGVars; i++) if(gVarData[i][gVarName][0] && !strcmp(gVarData[i][gVarName], varName, true))
  27.     {
  28.         gVarData[i][gVarValue] = valueVar;
  29.         encontrado = true;
  30.         break;
  31.     }
  32.    
  33.     if(!encontrado)
  34.     {
  35.         format(gVarData[++maxGVars][gVarName],128, "%s", varName);
  36.         gVarData[maxGVars][gVarValue] = valueVar;
  37.     }
  38.     return ++maxGVars, encontrado = false;
  39. }
  40.  
  41. GetGVarString(varName[])
  42. {
  43.     static returnString[128] = "Invalid GVar";
  44.     for(new i; i != maxGVars; i++) if(gVarData[i][gVarName][0] && !strcmp(gVarData[i][gVarName], varName, true))
  45.     {
  46.         format(returnString, 128, gVarData[i][gVarValue]);
  47.         break;
  48.     }
  49.     return returnString;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement