Advertisement
Guest User

Untitled

a guest
Mar 6th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. #include <a_samp>
  2. #define MAX_VARS 20
  3. enum varinfo { _name[24], _integer, _string[24], Float:_float }
  4. new v_var[MAX_VEHICLES][MAX_VARS][varinfo];
  5. stock SetVVarInt(__vehicleid, __name[24], __value)
  6. {
  7. if(__vehicleid == INVALID_VEHICLE_ID) return -1;
  8. new current_var, e_var=-1;
  9. for(new i = 0; i < MAX_VARS; i++)
  10. {
  11. if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; if(e_var == -1) e_var = i; continue; }
  12. if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0) { v_var[__vehicleid][current_var][_integer] = __value; return current_var; }
  13. current_var++;
  14. }
  15. if(e_var == -1) return -1;
  16. format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
  17. v_var[__vehicleid][e_var][_integer] = __value;
  18. return e_var;
  19. }
  20. stock GetVVarInt(__vehicleid,__name[24])
  21. {
  22. if(__vehicleid == INVALID_VEHICLE_ID) return -1;
  23. new current_var,_tmp;
  24. for(new i = 0; i < MAX_VARS; i++)
  25. {
  26. if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; continue; }
  27. if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0)
  28. { _tmp = v_var[__vehicleid][current_var][_integer]; break; }
  29. current_var++;
  30. }
  31. return _tmp;
  32. }
  33. stock SetVVarString(__vehicleid, __name[24], __string[24])
  34. {
  35. if(__vehicleid == INVALID_VEHICLE_ID) return -1;
  36. new current_var,e_var=-1;
  37. for(new i = 0; i < MAX_VARS; i++)
  38. {
  39. if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; if(e_var == -1) e_var = i; continue; }
  40. if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0)
  41. { format(v_var[__vehicleid][current_var][_string], 24, "%s", __string); return current_var; }
  42. current_var++;
  43. }
  44. if(e_var == -1) return -1;
  45. format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
  46. format(v_var[__vehicleid][e_var][_string], 24, "%s", __string);
  47. return e_var;
  48. }
  49. stock GetVVarString(__vehicleid,__name[24])
  50. {
  51. new _tmp[24] = "0";
  52. if(__vehicleid == INVALID_VEHICLE_ID) return _tmp;
  53. for(new i = 0; i < MAX_VARS; i++)
  54. {
  55. if(!v_var[__vehicleid][i][_name][0]) continue;
  56. if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0) { format(_tmp,24,"%s",v_var[__vehicleid][i][_string]); break; }
  57. }
  58. return _tmp;
  59. }
  60. stock SetVVarFloat(__vehicleid, __name[24], Float:__float)
  61. {
  62. if(__vehicleid == INVALID_VEHICLE_ID) return -1;
  63. new e_var=-1;
  64. for(new i = 0; i < MAX_VARS; i++)
  65. {
  66. if(!v_var[__vehicleid][i][_name][0]) { if(e_var == -1) e_var = i; continue; }
  67. if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0)
  68. { v_var[__vehicleid][i][_float] = __float; return i; }
  69. }
  70. format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
  71. v_var[__vehicleid][e_var][_float] = __float;
  72. return e_var;
  73. }
  74. forward Float:GetVVarFloat(__vehicleid,__name[24]);
  75. public Float:GetVVarFloat(__vehicleid,__name[24])
  76. {
  77. if(__vehicleid == INVALID_VEHICLE_ID) return -1.0;
  78. new Float:_tmp;
  79. for(new i = 0; i < MAX_VARS; i++)
  80. {
  81. if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0) { _tmp=v_var[__vehicleid][i][_float]; break; }
  82. }
  83. return _tmp;
  84. }
  85. stock DeleteVVar(__vehicleid,__name[24])
  86. {
  87. if(__vehicleid == INVALID_VEHICLE_ID) return -1;
  88. SetVVarInt(__vehicleid,__name,0);
  89. SetVVarFloat(__vehicleid,__name,0.0);
  90. SetVVarString(__vehicleid,__name,"0");
  91. return 1;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement