Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Casper on Feb 18, 2017, 10:37 AM

Title: /transferstats command please
Post by: Casper on Feb 18, 2017, 10:37 AM
Hi, please someone give me function /transferstats <Full Name> <New Name>
Title: Re: /transferstats command please
Post by: KAKAN on Feb 18, 2017, 01:02 PM
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 )
Title: Re: /transferstats command please
Post by: redax on Feb 18, 2017, 03:26 PM
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?
Title: Re: /transferstats command please
Post by: Cool on Feb 18, 2017, 03:39 PM
@KAKAN i dont understand Your code which Things willl be transfered with using this
Title: Re: /transferstats command please
Post by: EK.IceFlake on Feb 18, 2017, 03:52 PM
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.
Title: Re: /transferstats command please
Post by: KAKAN on Feb 18, 2017, 05:40 PM
iceflake, from what I see, the local keyword is the commented line and so it won't work :D
Title: Re: /transferstats command please
Post by: EK.IceFlake on Feb 18, 2017, 05:56 PM
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.
Title: Re: /transferstats command please
Post by: Casper on Feb 23, 2017, 05:07 PM
ok, thanks but I can't create functions. I don't have date base (browser)
Title: Re: /transferstats command please
Post by: Eva on Feb 23, 2017, 05:24 PM
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