Transferstats Command

Started by Abbas_905, Mar 20, 2024, 04:08 AM

Previous topic - Next topic

Abbas_905

else if ( cmd == "transferstats" )
{
       if ( !text ) MessagePlayer("Error: Please use the correct syntax.  /transferstats <newnick>.", player );
       else
       {
       local newnick = text,
       pn = QuerySQL(sqliteDB, " SELECT Name FROM Accounts WHERE Name='"+player.Name+"' "),
       n = QuerySQL(sqliteDB, " SELECT Name FROM Accounts WHERE Name='"+newnick+"' "),
       aldname = GetSQLColumnData(n, 0),
       oldname = GetSQLColumnData(pn, 0);
       if ( newnick == player.Name ){
       MessagePlayer("Error: Your new name cannot be the same nickname.",player); return false;}
       else if ( aldname != null ) { MessagePlayer("Error:This name is already registered by someone.",player); return false;}
else
{
QuerySQL(sqliteDB, "UPDATE Accounts SET Name='"+newnick+"', NameLower='"+newnick.tolower() +"'  WHERE Name='"+oldname+"' ");
         QuerySQL(Spawnweps, "UPDATE SpawnWep SET Name='"+newnick+"' WHERE Name='"+oldname+"' ");
         QuerySQL(SpawnLoc, "UPDATE Spawnloc SET player='"+newnick+"' WHERE player='"+oldname+"'");
         player.Name=text;
         MessagePlayer("Successfully changed your nickname to " + newnick  +"!",player);
         }
         FreeSQLQuery( pn );
         FreeSQLQuery( n );
         }
         }