/transferstats command please

Started by Casper, Feb 18, 2017, 10:37 AM

Previous topic - Next topic

Casper

Hi, please someone give me function /transferstats <Full Name> <New Name>

KAKAN

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 )
oh no

redax

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?

Cool

@KAKAN i dont understand Your code which Things willl be transfered with using this

EK.IceFlake

#4
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.

KAKAN

iceflake, from what I see, the local keyword is the commented line and so it won't work :D
oh no

EK.IceFlake

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.

Casper

ok, thanks but I can't create functions. I don't have date base (browser)

Eva