BUILDIN(setarray) { struct script_data* data; const char* name; int32 start; int32 end; int32 id; int32 i; TBL_PC* sd = NULL; data = script_getdata(st, 2); if( !data_isreference(data) ) { ShowError("script:setarray: not a variable\n"); script_reportdata(data); st->state = END; return false;// not a variable } id = reference_getid(data); start = reference_getindex(data); name = reference_getname(data); if( not_array_variable(*name) ) { ShowError("script:setarray: illegal scope\n"); script_reportdata(data); st->state = END; return false;// not supported } if( not_server_variable(*name) ) { sd = script_rid2sd(st); if( sd == NULL ) return true;// no player attached } end = start + script_lastdata(st) - 2; if( end > SCRIPT_MAX_ARRAYSIZE ) end = SCRIPT_MAX_ARRAYSIZE; if( is_string_variable(name) ) {// string array for( i = 3; start < end; ++start, ++i ) set_reg(st, sd, reference_uid(id, start), name, (void*)script_getstr(st,i), reference_getref(data)); } else {// int array for( i = 3; start < end; ++start, ++i ) set_reg(st, sd, reference_uid(id, start), name, (void*)__64BPTRSIZE(script_getnum(st,i)), reference_getref(data)); } return true; }