Away From Keyboard SystemonScriptLoad()
{
pAway <- {};
oldname <- array( GetMaxPlayers(), null );
}
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;
}
}
//Your shitty codes here.
}
function onPlayerJoin( player )
{
if(pAway.rawin(player.Name))
{
Message("Kicked "+player.Name+", Reason: A player with same nick already exist");
player.Kick();
}
}
function onPlayerPart( player, reason )
{
if (pAway.rawin(oldname[player.ID])) // place it in first line
{
player.Name = ""+oldname[player.ID]+"";
pAway.rawdelete( player.Name );
oldname[player.ID] = null;
}
}
function onPlayerChat(player, text)
{
if ( text == "afk" || text == "AFK" )
{
if (pAway.rawin(oldname[player.ID])) MessagePlayer("Failure - You Have Already Used AFK, try BACK Instead",player);
else{
Message(player+" Is Now AFK!");
EchoMessage(player+" Is Now AFK!");
oldname[player.ID]= player.Name;
pAway.rawset(player.Name, "afk");
player.Name = ""+player.Name+"(AFK)";
}
}
else if ( text == "back" || text == "BACK" )
{
if (!pAway.rawin(oldname[player.ID])) MessagePlayer("Failure - You Haven't Used AFK",player);
else{
Message(""+oldname[player.ID]+" Is Now Back!");
EchoMessage(""+oldname[player.ID]+" Is Now Back!");
player.Name = ""+oldname[player.ID]+"";
pAway.rawdelete( player.Name );
oldname[player.ID] = null;
}
}
return 1;
}
Updated: On Table now Thanks To @rulk and @NE.CrystalBlue For Examples
You could use Table/Array to store the nicks, why SQLite?
Quote from: Doom_Killer on Jul 24, 2015, 08:47 AMYou could use Table/Array to store the nicks, why SQLite?
Bro i created this months ago, i was working on GHP script and stopped working, SQlite felt me easy to create it faster.
Btw could you tell me about the saving nick and status in array
Indeed, why make it so laggy when you already set someone's status back when they leave. SQLite is better for saving persistent data, that needs to survive server restarts.
Quote from: Thijn on Jul 24, 2015, 09:22 AMIndeed, why make it so laggy when you already set someone's status back when they leave. SQLite is better for saving persistent data, that needs to survive server restarts.
You mean this is better with sqlite,
@Thijn
Quote from: Beztone on Jul 24, 2015, 09:27 AMQuote from: Thijn on Jul 24, 2015, 09:22 AMIndeed, why make it so laggy when you already set someone's status back when they leave. SQLite is better for saving persistent data, that needs to survive server restarts.
You mean this is better with sqlite,
@Thijn
No, he says not to use sqlite and your making this afk off after he leaves server and if you want to use database use only if you want to save even after server restarts but your turned it off . so what is the use of database which just creates lag better make a array/table
I used that in onPlayerPart because if the player nick remains as afk then the server wont save the stats data.
Beztone(afk) left server
Error nick not found in accounts table ( stats lost )
But if use PartWhenAway then
Beztone left server nick founded (stats saved)
I'd tested everything before releasing it
You can still do that with array/table Beztone.
Quote from: Doom_Killer on Jul 24, 2015, 12:19 PMYou can still do that with array/table Beztone.
Ok i will update the topic when i'll done that
You do not return 1 in onPlayerChat. This will cause chat messages by players to not appear.
At the top, you use "\\" for commenting. This will return a compiletime syntax error.
Quote from: NE.CrystalBlue on Jul 24, 2015, 07:30 PMYou do not return 1 in onPlayerChat. This will cause chat messages by players to not appear.
That was not necessary because everyone already had that in their scripts, btw added
Quote from: NE.CrystalBlue on Jul 24, 2015, 07:30 PMAt the top, you use "\" for commenting. This will return a compiletime syntax error.
I was confused about text ignoring slashes thanks
u didn't added oldname in playerclass
BUMP!
System Updated To Table no more SQLite
@Thijn would you please clean the topic :)
if you dont mind
Its good to see you putting in the effort to learn from the advice given to you
@Kusanagithumbs up from me :-)
Nice update.
This would help the newbies very much.
Nice work. :)
Just 1 suggestion( not a bug )
Add the same thing to onScriptUnload()
Because if someone uses this, and he shut-downs the server when someone had been AFK after killing 100 of players.
Will that guy be able to save his/her stats? Nope.
Quote from: KAKAN on Oct 24, 2015, 06:29 AMJust 1 suggestion( not a bug )
Add the same thing to onScriptUnload()
Because if someone uses this, and he shut-downs the server when someone had been AFK after killing 100 of players.
Will that guy be able to save his/her stats? Nope.
I'll see about that but there are much things that you guys have to implement yourself such as checking nick before saving stats ( i believe that there are many servers those have timers that saves stats each 3 minutes) btw for onScriptUnload() you can create a loop that could change nick and save data of each player if it is possible
Simple, add this in the onScriptUnload()
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;
}
}
//Your shitty codes here.
}
I already made this code last night but i lost internet :D
Updated
Nice work.
After getting back from my trip.
I'll test it and have a full bug test.