I know i used a quiet bad way but its easy to learn for newbies must read my comments in the code
/* Hello i am bringing this system for those who need it but ensure that you change every thing in this system that in incompatable with your script such as Database, Messages, Functions like GetLevel */
function onScriptLoad()
{
db <- ConnectSQL("staff.sqlite");
QuerySQL( db, "CREATE TABLE IF NOT EXISTS StaffList ( Name TEXT, Level INT, State TEXT )" );
}
function onPlayerCommand( player, cmd, text
{
if ( cmd == "stafflist" )
{
if ( GetLevel(player) < 2 ) return 0; // Change this if you want
else
{
local q = QuerySQL(db, "SELECT * FROM StaffList"),a=0;
if( !GetSQLColumnData( q, 0 ) ) MessagePlayer(">> None Of Staff Member Has Been Added Yet.",player);
else
{
while( GetSQLColumnData( q, 0 ) )
{
MessagePlayer(GREY+">> (" + GetSQLColumnData( q, 0 ) + " :: " + GetSQLColumnData( q, 1 ) + " :: " + GetSQLColumnData( q, 2 ) + ")",player );
GetSQLNextRow( q );
a++;
}
}
FreeSQLQuery(q);
}
}
}
checkingstaff( player ); // put this in your login function and autologin function such as AccInfo and in your setlevel command
function checkingstaff( player )
{
if ( GetLevel(player) >= 2 ) // Change It if you aren't using GetLevel Function or change the numeric values
{
local sl = QuerySQL( db, "SELECT * FROM StaffList WHERE Name='" + player.Name + "'" );
if ( GetSQLColumnData( sl, 0 ) == null )
{
QuerySQL(db, "INSERT INTO StaffList (Name, Level, State) VALUES ('"+ player.Name +"', '"+ GetLevel(player) +"', '"+ GetLevelTag(player) +"')");
}
else
{
QuerySQL(db, "UPDATE StaffList SET Level='" + GetLevel(player) + "' WHERE Name='" + player.Name + "'");
QuerySQL(db, "UPDATE StaffList SET State='" + GetLevelTag(player) + "' WHERE Name='" + player.Name + "'");
}
FreeSQLQuery(sl);
}
else
{
QuerySQL(db, "DELETE FROM StaffList WHERE Name='"+player.Name+"'");
}
}
function GetLevelTag(player) // this function is used for State in Stafflist
{
local lvl = GetLevel(player);
if( lvl == 1 ) return "Member";
if( lvl == 2 ) return "Moderator";
if( lvl == 3 ) return "Admin";
if( lvl == 4 ) return "Head Admin";
if( lvl == 5 ) return "Manager";
if( lvl == 6 ) return "Server Owner";
}
function GetLevel( player ) // dont add it if you have your own
{
local lvl = GetSQLColumnData( QuerySQL( db, "SELECT Level FROM Account WHERE Name='" + player.Name + "'" ), 0 );
if ( lvl ) return lvl;
else return 0;
FreeSQLQuery( lvl );
}
checkingstaff updated the index sl doesnt exist fixed., levels updated
Nice btw use this, this one is pretty easy
function GetLevelTag(player) // this function is used for State in Stafflist
{
local lvl = GetLevel(player);
switch(lvl)
{
case 1: return "User";
case 2: return "V.I.P";
case 3: return "Moderator";
case 4: return "Admin";
case 5: return "Head Admin";
case 6: return "Owner";
}
}
error I Add checkingstaff onPlayerDeath when i do /kill console says the index sl does not exist
Did you added the sl variable?
Quote from: FinchDon on Sep 08, 2015, 02:52 PMerror I Add checkingstaff onPlayerDeath when i do /kill console says the index sl does not exist
Seriously
onPlayerDeath :-\
Good one, will be helpfull for players who really needs this.
Why don't you make a array and check the level's of players instead of selecting the player's level from the database? (for stafflist command and checkingstaff function) :)
But how can we insert an offline admin status to array,
Quote from: Kusanagi on Sep 08, 2015, 04:22 PMBut how can we insert an offline admin status to array,
The thing which i meant here is about
GetLevel function which can be used by a array or a array with a class.
Quote from: Mashreq on Sep 08, 2015, 04:23 PMQuote from: Kusanagi on Sep 08, 2015, 04:22 PMBut how can we insert an offline admin status to array,
The thing which i meant here is about GetLevel function which can be used by a array or a array with a class.
That function isnt recommended everyone has their own GetLevel, so they can use their own
Oh btw using array in his script is converting the whole one
Better one tho:-
function GetLevel( player )
{
return stats[ player.ID ].Level;
//Change it according to your script.
}
I pointed out 1 bug without even trying it...
AND THE BUG IS:-
You have missed this on onScriptLoad()
db <- ConnectSQL("staff.sqlite");
NOTE: Sorry for spamming
And yes:-
in the checkinfstaff function
add this:-
if( GetLevel(player) >= 2 )
Instead ofif ( GetLevel(player) == 3 || GetLevel(player) == 5 || GetLevel(player) == 7 || GetLevel(player) == 9 || GetLevel(player) == 10 )
THIS one is better i guess
Quote from: KAKAN on Sep 08, 2015, 06:05 PMI pointed out 1 bug without even trying it...
AND THE BUG IS:-
You have missed this on onScriptLoad()
db <- ConnectSQL("staff.sqlite");
NOTE: Sorry for spamming
I recommend to use Global database ( where your other tables are created like accounts ) btw added
Quote from: KAKAN on Sep 08, 2015, 06:11 PMAnd yes:-
in the checkinfstaff function
add this:-
if( GetLevel(player) >= 2 )
Instead ofif ( GetLevel(player) == 3 || GetLevel(player) == 5 || GetLevel(player) == 7 || GetLevel(player) == 9 || GetLevel(player) == 10 )
THIS one is better i guess
I done this because if by mistake we set someone's level 4 instead 3 then that will not be added in stafflist because he isnt admin but if you use levels like 2,3,4.5,6 then you can do it by yourself
Why would you set levels like that. Level 3 is admin, level 4 is not, level 5 is. What kinda sense is that?
Quote from: Thijn on Sep 08, 2015, 07:12 PMWhy would you set levels like that. Level 3 is admin, level 4 is not, level 5 is. What kinda sense is that?
Idk but some members likes the levels like this, is this necessary to discuss just end it here i am gonna change levels in system
So Where i add that???? it always say sl does not exist
Post the full error. Including locals.
Quote from: Kusanagi on Sep 08, 2015, 06:20 PMQuote from: KAKAN on Sep 08, 2015, 06:05 PMI pointed out 1 bug without even trying it...
AND THE BUG IS:-
You have missed this on onScriptLoad()
db <- ConnectSQL("staff.sqlite");
NOTE: Sorry for spamming
I recommend to use Global database ( where your other tables are created like accounts ) btw added
I too, but what about a blank script
Thanks Fixed
What a Superb function i like this @kusanagi
Quote from: Wolf on Oct 03, 2015, 03:45 PMWhat a Superb function i like this @kusanagi
Stop bumping old topics to say thanks. There's a Like button for a reason...
Which
Quote from: Wolf on Oct 03, 2015, 03:54 PMWhich
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi0.kym-cdn.com%2Fphotos%2Fimages%2Fnewsfeed%2F000%2F173%2F576%2FWat8.jpg%3F1315930535&hash=6d43be9c940111ec2e6e00876606f99fb71ef0f5)
@Thijn So Once Again Day is Same Thanks to Wolf for bump
We know
@Stuart Eldin that you are
@FinchDon so anyone can't believe you.
You both make no sense for real!
OK Wolf I am Finch So What the fuck you can do? Ah?
Locked