19.06.2011, 15:19
It should return -1 in that case. Can you try in your format change %d to %i and look if slot is -1 then
#define vector_enum_cell<%0,%1> for (new _%0_it = 0, %1 = 0 ; (_%0_it < vector_size(%0) && (%1 = vector_get(%0,_%0_it))) ; _%0_it++) #define vector_enum_float<%0,%1> for (new _%0_it = 0, Float:%1 = 0 ; (_%0_it < vector_size(%0) && (%1 = vector_get_float(%0,_%0_it))) ; _%0_it++) #define vector_enum_arr<%0,%1,%2> for (new _%0_it = 0, %1[%2] ; (_%0_it < vector_size(%0) && (vector_get_arr(%0,_%0_it,%1,%2))) ; _%0_it++)
new vector_id = 0, index = 0; vector_push_back_arr(vector_id, "Hello, World!"); vector_push_back_arr(vector_id, "Hello to you too."); vector_enum_arr<vector_id, curStr, 128> { printf("index %i: %s", index, curStr); index++; } vector_clear(vector_id);
vector_enum_cell<vectorid, currentcell> Specify vector to enumerate in vectorid. Specify variable name to store current cell. vector_enum_float<vectorid, currentfloat> Specify vector to enumerate in vectorid. Specify variable name to store current float. vector_enum_arr<vectorid, currentarr, length> Specify vector to enumerate in vectorid. Specify variable name to store current array. Specify length for currentarr (if vector contains array larger than it, its truncated)
#if defined _cstl_inc
#endinput
#endif
#define _cstl_inc
#pragma library cstl
#define VEC_ENTRY_TYPE_CELL 1
#define VEC_ENTRY_TYPE_ARRAY 2
#define VEC_ENTRY_TYPE_FLOAT 3
// VECTOR
native vector_push_back(vecid, element); // push element
native vector_push_back_float(vecid, Float:element); // push element
native vector_push_back_arr(vecid, const element[]); // push array
native vector_size(vecid); // get vector size
native vector_get(vecid, id); // get element
native Float:vector_get_float(vecid, id); // get floating point number
native vector_get_arr(vecid, id, buffer[], buflen = sizeof(buffer)); // get array element to buffer
native vector_set(vecid, id, element); // set cell
native vector_set_float(vecid, id, Float:element); // set cell
native vector_set_arr(vecid, id, const element[]); // set array
native vector_clear(vecid); // clear vector
native vector_resize(vecid, newsize); // attention!: reducing size causes memory leaks if array pointers are removed
native vector_entry_type(vecid, id); // get element type
native vector_remove(vecid, id); // remove element by ID
native vector_find(vecid, element); // find ID of int element
native vector_find_float(vecid, Float:element); // find ID of float element
native vector_find_arr(vecid, const element[]); // find ID of array
native vector_globalize(vecid); // makes vector visible to all scripts
native vector_deglobalize(vecid); // deglobalizes vector (vector removed from all scripts except calling script)
native vector_is_globalized(vecid); // is vector ID globalized
native vector_index_exists(vecid, index); // does index exist
// MAP
native map_insert(mapid, const key[], value);
native map_insert_float(mapid, const key[], Float:value);
native map_insert_arr(mapid, const key[], const value[]);
native map_get(mapid, const key[]);
native Float:map_get_float(mapid, const key[]);
native map_get_arr(mapid, const key[], buffer[], buflen = sizeof(buffer));
native map_size(mapid);
native map_remove(mapid, const key[]);
native map_contains(mapid, const key[]);
native map_entry_type(mapid, const key[]);
native map_clear(mapid);
native map_globalize(mapid); // makes map visible to all scripts
native map_deglobalize(mapid); // deglobalizes map (map removed from all scripts except calling script)
native map_is_globalized(mapid); // is map ID globalized
I'm experiencing an issue with this plugin. Everything works very nicely on Windows, but last night I figured I had to compile the plugin on my own for Linux (CentOS to be more precise). I was getting some library errors prior to that.
A link to the version I compiled: http://sf-se.net/dev/cstl.so Now to the main problem - maps do not work. Everything to do with maps will make the server lock up. Again, this must be an issue with my plugin version and my server setup. Vectors work like charm. Can anyone think of a way to fix this? |
try { maps[amx][mapid].erase(maps[amx][mapid].find(key)); } catch(std::exception e) { }