scriptunload

Started by Cool, May 26, 2016, 10:10 AM

Previous topic - Next topic

Cool

when scripts unloading error occuring
functions function onScriptUnload(){
local I, player, mp = GetMaxPlayers();
for(I = 0; I < mp; ++I ){ // place it in first line
player = FindPlayer( I )
if (pAway.rawin(oldname[player.ID]))
{
player.Name = ""+oldname[player.ID]+"";
pAway.rawdelete( player.Name );
oldname[player.ID] = null;
}
}
if( sqliteDB ){
DisconnectSQL( sqliteDB );
sqliteDB = null;
}
    DisconnectSQL( secondarydb );
print( "Fuzzie's Account System v3 - SQLite variant has successfully unloaded..." );
}

DizzasTeR

player = FindPlayer( I )
Are you checking if the player is even valid and exists? what if there is no player connected at ID 0, 1, 2, 3... because you're I is looping and if there is no player at that I id then player will be null and player.ID will not exist.

so check if the player exists by
if( player ) {
/* your code here */
}

/* other code here */

.

Quote from: Doom_Kill3R on May 26, 2016, 10:34 AMAre you checking if the player is even valid and exists?...

Oh man, that was a good laugh. Did you forgot where you are or what? ;D
.

KAKAN

Quote from: . on May 26, 2016, 10:45 AM
Quote from: Doom_Kill3R on May 26, 2016, 10:34 AMAre you checking if the player is even valid and exists?...

Oh man, that was a good laugh. Did you forgot where you are or what? ;D
^^^^^^^^^^^^^

This one should work:-
function onScriptUnload(){
local I, player, mp = GetMaxPlayers();
for(I = 0; I < mp; ++I ){ // place it in first line
player = FindPlayer( I );
if( !player ) continue;
else if (pAway.rawin(oldname[player.ID]))
{
player.Name = ""+oldname[player.ID]+"";
pAway.rawdelete( player.Name );
oldname[player.ID] = null;
}
}
if( sqliteDB ){
 DisconnectSQL( sqliteDB );
 sqliteDB = null;
 }
     DisconnectSQL( secondarydb );
 print( "Fuzzie's Account System v3 - SQLite variant has successfully unloaded..." );
}
oh no