Hi, please someone give me function /transferstats <Full Name> <New Name>
player_stats <- {};
function onPlayerJoin( player ){
local isthere = player_stats.rawin( player.Name );
if( isthere ) player.Name = player_stats.rawget( player.Name );
}
function onPlayerCommand( invoker, command, arguments ){
if( command == "transferstats" ){
if( !text ) return;
text = split(text," ");
if( text.len() < 2 ) return;
player_stats.rawset( text[0], text[1] );
local plr = FindPlayer( text[1] );
if( plr ) plr.Kick();
local player = FindPlayer( text[0] );
if( player ) player.Name = text[1];
}
}
There you go :) ( forum f*ks up everything. )( untested code )
Quote from: [MDt]Casper on Feb 18, 2017, 10:37 AMHi, please someone give me function /transferstats <Full Name> <New Name>
What stats you want to transfer?are they stored in a SQL table?
@KAKAN i dont understand Your code which Things willl be transfered with using this
Quote from: [MDt]Casper on Feb 18, 2017, 10:37 AMHi, please someone give me function /transferstats <Full Name> <New Name>
Here, untested.
else if (cmd == "transferstats")
{
//params = your params array, local params = split(parameters, " ");
if (params.len() < 2) MessagePlayer("Syntax invalid", player);
else
{
QuerySQL(db, "update players set name = '" + params[1] + "' where lower(name) = '" params[0].tolower() "'");
}
}
Prerequisites:
You're using SQLite
Your database instance is db
Your table for players is called players
Their names are stored in the column name
Make sure to join this with an admin system.
iceflake, from what I see, the local keyword is the commented line and so it won't work :D
Quote from: KAKAN on Feb 18, 2017, 05:40 PMiceflake, from what I see, the local keyword is the commented line and so it won't work :D
Well, in my scripts, that parameter is defined right at the top of onplayercommand, but this probably isn't the case here, so I made that on the commented line so that if that isnt the case then you could use that.
ok, thanks but I can't create functions. I don't have date base (browser)
Quote from: [MDt]Casper on Feb 23, 2017, 05:07 PMok, thanks but I can't create functions. I don't have date base (browser)
https://github.com/sqlitebrowser/sqlitebrowser/releases