Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define MAX_VARS 20
- enum varinfo { _name[24], _integer, _string[24], Float:_float }
- new v_var[MAX_VEHICLES][MAX_VARS][varinfo];
- stock SetVVarInt(__vehicleid, __name[24], __value)
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1;
- new current_var, e_var=-1;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; if(e_var == -1) e_var = i; continue; }
- if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0) { v_var[__vehicleid][current_var][_integer] = __value; return current_var; }
- current_var++;
- }
- if(e_var == -1) return -1;
- format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
- v_var[__vehicleid][e_var][_integer] = __value;
- return e_var;
- }
- stock GetVVarInt(__vehicleid,__name[24])
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1;
- new current_var,_tmp;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; continue; }
- if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0)
- { _tmp = v_var[__vehicleid][current_var][_integer]; break; }
- current_var++;
- }
- return _tmp;
- }
- stock SetVVarString(__vehicleid, __name[24], __string[24])
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1;
- new current_var,e_var=-1;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(!v_var[__vehicleid][current_var][_name][0]) { current_var++; if(e_var == -1) e_var = i; continue; }
- if(strcmp(v_var[__vehicleid][current_var][_name], __name, true) == 0)
- { format(v_var[__vehicleid][current_var][_string], 24, "%s", __string); return current_var; }
- current_var++;
- }
- if(e_var == -1) return -1;
- format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
- format(v_var[__vehicleid][e_var][_string], 24, "%s", __string);
- return e_var;
- }
- stock GetVVarString(__vehicleid,__name[24])
- {
- new _tmp[24] = "0";
- if(__vehicleid == INVALID_VEHICLE_ID) return _tmp;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(!v_var[__vehicleid][i][_name][0]) continue;
- if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0) { format(_tmp,24,"%s",v_var[__vehicleid][i][_string]); break; }
- }
- return _tmp;
- }
- stock SetVVarFloat(__vehicleid, __name[24], Float:__float)
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1;
- new e_var=-1;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(!v_var[__vehicleid][i][_name][0]) { if(e_var == -1) e_var = i; continue; }
- if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0)
- { v_var[__vehicleid][i][_float] = __float; return i; }
- }
- format(v_var[__vehicleid][e_var][_name], 24, "%s", __name);
- v_var[__vehicleid][e_var][_float] = __float;
- return e_var;
- }
- forward Float:GetVVarFloat(__vehicleid,__name[24]);
- public Float:GetVVarFloat(__vehicleid,__name[24])
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1.0;
- new Float:_tmp;
- for(new i = 0; i < MAX_VARS; i++)
- {
- if(strcmp(v_var[__vehicleid][i][_name], __name, true) == 0) { _tmp=v_var[__vehicleid][i][_float]; break; }
- }
- return _tmp;
- }
- stock DeleteVVar(__vehicleid,__name[24])
- {
- if(__vehicleid == INVALID_VEHICLE_ID) return -1;
- SetVVarInt(__vehicleid,__name,0);
- SetVVarFloat(__vehicleid,__name,0.0);
- SetVVarString(__vehicleid,__name,"0");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement