Id like someone to take a look at this piece of code and tell me any errors to correct, ms-vc++ 6.0 says there are 3, but when I correct them it creates more errors (example being: going from 3 errors to 18 with one ';' going in)
Help appreciated.
Here is the code:
// --------------------- Database Management Library ---------------------------------
// Do not modify this.
function script func_searchdb {
set $@array_size, getarraysize(getarg(0));
for(set $@db_count, 0; $@db_count < $@array_size; set $@db_count, $@db_count + 1){
if(getelementofarray(getarg(0), $@db_count) == getarg(1))
return $@db_count;
}
return -1;
}
function script func_addentry {
if(getarraysize(getarg(0)) < 127) {
if(getarg(0) != 0)
set getelementofarray(getarg(0), getarraysize(getarg(0))), getarg(1);
else
set getarg(0), getarg(1);
return 0;
}
return 1;
}
function script func_removeentry {
set $@re_entry, callfunc("func_searchdb", getarg(0), getarg(1));
if($@re_entry != -1)
deletearray getelementofarray(getarg(0),$@re_entry),1;
return;
}
// --------------------------- Core Function -----------------------------------------
// Do not modify this.
function script func_soundall {
set $@rid_backup, playerattached();
for(set $@dbe_cnt2, 0; $@dbe_cnt2 < $@rid_dbe_num; set $@dbe_cnt2, $@dbe_cnt2+1) {
set $@database_name$, getarg(0) + $@dbe_cnt2;
set $@array_size, getarraysize(getd($@database_name$));
for(set $@sa_count, 0; $@sa_count < $@array_size; set $@sa_count, $@sa_count + 1){
if(attachrid(getelementofarray(getd($@database_name$), $@sa_count)) != 0)
soundeffect getarg(1), 0;
}
}
attachrid $@rid_backup;
return;
}
// --------------------------- Database Handler --------------------------------------
// Modify according to your needs.
- script database_handler -1,{
end;
OnInit:
// The base database name
set $@rid_database_name$, "$@rid_database_";
// The maximum number of database to allocate
// Adjust this to your needs, each database is capable of holding 127 players.
set $@rid_dbe_num,;
end;
}
// ------------------------ Login/Logout Events --------------------------------------
// Modify this depending on your server's configurations.
// If event_type is set to label mode, be sure to modify the code below.
- script PCLoginEvent -1,{
set $@dbe_cnt,;
while(callfunc("func_addentry", getd($@rid_database_name$ + $@dbe_cnt), playerattached()) != 0)
set $@dbe_cnt, $@dbe_cnt + 1;
set soundall_database, $@dbe_cnt;
end;
}
- script PCLogoutEvent -1,{
callfunc "func_removeentry", getd($@rid_database_name$ + soundall_database), playerattached();
end;
}
// -------------------------- Sample Script -----------------------------------------
// To use this library, call the function func_soundall
// Syntax:
// callfunc "func_soundall", <rid-array-variable>, <wav-file>;
prontera.gat,180,200,4 Sampler 111,{
callfunc "func_soundall", $@rid_database_name$, "se_organ02";
end;
}