setnick problem

Started by Cool, Jun 29, 2016, 11:11 PM

Previous topic - Next topic

Cool

i am try to make an cmds to change their nickname if they are offline i make that cmds but error The index Name does not exists
else if ( cmd == "sn" )
{
if ( GetLevel(player) < 0 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 7 to access the command",player );
else if ( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF] / " + cmd + " [OLD/NICK] [New/Nick]", player );       
else {
local plr = GetTok(text, " ", 1);
if (plr== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else {
local nick = GetTok(text, " ", 2);
if ( nick== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else {
local q = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE Name='"+plr+"'");
local q = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + plr.Name.tolower() + "'" );
local q = QuerySQL( sqliteDB, "SELECT * FROM Properties  WHERE Name='"+plr+"'");
if ( GetSQLColumnData(q, 0) )
                {
MessagePlayer("[#4682B4][INFO][#FFFFFF]You changed nick of " + plr + " To: " +nick+ ".",player);
MessagePlayer("[#4682B4][INFO][#FFFFFF]Admin " + player.Name + " changed your nick To: " +nick+ ". Don't Forget It!",player);
QuerySQL(sqliteDB,"UPDATE Accounts SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Accounts SET NameLower='" +nick.tolower()+ "' WHERE NameLower='"+plr.tolower()+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Properties SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
}
else MessagePlayer("Invalid Nick/ID Specified!",player );
      FreeSQLQuery( q );
}
}
}
}

Mashreq

There were many mistakes in your command, the following command should work perfectly for you.

else if ( cmd == "sn" )
{
if ( GetLevel(player) < 0 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 7 to access the command",player );
else if ( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF] / " + cmd + " [OLD/NICK] [New/Nick]", player );       
else
{
local plr = GetTok(text, " ", 1), nick = GetTok(text, " ", 2);
if (plr== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else if ( nick== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else
 {
local q = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + plr.tolower() + "'");
local q1 = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + nick.tolower() + "'" );
if ( GetSQLColumnData(q, 0) )
                {
if ( !GetSQLColumnData(q1, 0) )
               {
MessagePlayer("[#4682B4][INFO][#FFFFFF]You changed nick of " + plr + " To: " +nick+ ".",player);
if ( FindPlayer( plr ) ) {
MessagePlayer("[#4682B4][INFO][#FFFFFF]Admin " + player.Name + " changed your nick To: " +nick+ ". Don't Forget It!", FindPlayer( plr ) );
FindPlayer( plr ).Name = nick;
}
QuerySQL(sqliteDB,"UPDATE Accounts SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Accounts SET NameLower='" +nick.tolower()+ "' WHERE NameLower='"+plr.tolower()+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Properties SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
}
else MessagePlayer( nick + " is already a registered user." ,player );
}
else MessagePlayer( plr + " is not a registered user." ,player );
      FreeSQLQuery( q );
FreeSQLQuery( q1 );
}
}
}

Cool

Thanks but will you please take a look at it i added some more queries is it fine
else if ( cmd == "sn" )
{
if ( GetLevel(player) < 0 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 7 to access the command",player );
else if ( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF] / " + cmd + " [OLD/NICK] [New/Nick]", player );       
else
{
local plr = GetTok(text, " ", 1), nick = GetTok(text, " ", 2);
if (plr== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else if ( nick== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else
 {
local q = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + plr.tolower() + "'");
local q1 = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + nick.tolower() + "'" );
if ( GetSQLColumnData(q, 0) )
                {
if ( !GetSQLColumnData(q1, 0) )
               {
MessagePlayer("[#4682B4][INFO][#FFFFFF]You changed nick of " + plr + " To: " +nick+ ".",player);
if ( FindPlayer( plr ) ) {
MessagePlayer("[#4682B4][INFO][#FFFFFF]Admin " + player.Name + " changed your nick To: " +nick+ ". Don't Forget It!", FindPlayer( plr ) );
FindPlayer( plr ).Name = nick;
}
QuerySQL(sqliteDB,"UPDATE Accounts SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Accounts SET NameLower='" +nick.tolower()+ "' WHERE NameLower='"+plr.tolower()+"'");
    Message("DONE");
QuerySQL(sqliteDB,"UPDATE Properties SET Owner='"+nick+"' WHERE Owner='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE Cars SET Owner='"+nick+"' WHERE Owner='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE LMS SET Name='"+nick+"' WHERE Name='"+plr+"'");
    Message("DONE");
}
else MessagePlayer( nick + " is already a registered user." ,player );
}
else MessagePlayer( plr + " is not a registered user." ,player );
      FreeSQLQuery( q );
FreeSQLQuery( q1 );
}

Mashreq

It looks okay for me. Does that throw any errors?

Cool

hi the cmd is working perfect but 3 query not works when i change a player name when he offlile 3 query are following
QuerySQL(sqliteDB,"UPDATE LMS SET Name='" +nick.tolower()+ "' WHERE Name='"+plr.tolower()+"'");
QuerySQL(sqliteDB,"UPDATE Spawnwep SET Nick='"+nick+"' WHERE Nick='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE Spawnloc SET Name='"+nick+"' WHERE Name='"+plr+"'");
else if ( cmd == "sn" )
{
if ( GetLevel(player) < 0 ) MessagePlayer (" [#4682B4][Error][#FFFFFF]You must need atleast level 7 to access the command",player );
else if ( !text ) MessagePlayer("[#4682B4][Syntax][#FFFFFF] / " + cmd + " [OLD/NICK] [New/Nick]", player );       
else
{
local plr = GetTok(text, " ", 1), nick = GetTok(text, " ", 2);
if (plr== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else if ( nick== null) MessagePlayer("[#4682B4][ERROR][#FFFFFF]Please Insert A Valid Nick!", player );
else
 {
local q = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + plr.tolower() + "'");
local q1 = QuerySQL( sqliteDB, "SELECT * FROM Accounts WHERE NameLower='" + nick.tolower() + "'" );
if ( GetSQLColumnData(q, 0) )
                {
if ( !GetSQLColumnData(q1, 0) )
               {
MessagePlayer("[#4682B4][INFO][#FFFFFF]You changed nick of " + plr + " To: " +nick+ ".",player);
if ( FindPlayer( plr ) ) {
MessagePlayer("[#4682B4][INFO][#FFFFFF]Admin " + player.Name + " changed your nick To: " +nick+ ". Don't Forget It!", FindPlayer( plr ) );
FindPlayer( plr ).Name = nick;
}
QuerySQL(sqliteDB,"UPDATE Accounts SET Name='"+nick+"' WHERE Name='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE Accounts SET NameLower='" +nick.tolower()+ "' WHERE NameLower='"+plr.tolower()+"'");
QuerySQL(sqliteDB,"UPDATE Properties SET Owner='"+nick+"' WHERE Owner='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE Cars SET Owner='"+nick+"' WHERE Owner='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE LMS SET Name='" +nick.tolower()+ "' WHERE Name='"+plr.tolower()+"'");
QuerySQL(sqliteDB,"UPDATE Spawnwep SET Nick='"+nick+"' WHERE Nick='"+plr+"'");
QuerySQL(sqliteDB,"UPDATE Spawnloc SET Name='"+nick+"' WHERE Name='"+plr+"'");
}
else MessagePlayer( nick + " is already a registered user." ,player );
}
else MessagePlayer( plr + " is not a registered user." ,player );
      FreeSQLQuery( q );
FreeSQLQuery( q1 );
}
}
}

Mashreq

How is name stored in the table - LMS, Spawnwep and Spawnloc?

For example your name is Hercules,
  • In LMS, how it is stored as? (Hercules or hercules)
  • In Spawnwep, how it is stored as? (Hercules or hercules)
  • In Spawnloc, how it is stored as? (Hercules or hercules)

Cool

In lms    hercules   
in spawnwep  and spawnloc tables written in different cases like [RR]HeRcUlEs

KAKAN

Quote from: Hercules on Jun 30, 2016, 03:58 PMIn lms    hercules   
in spawnwep  and spawnloc tables written in different cases like [RR]HeRcUlEs
that's the problem
oh no

Cool

Quote from: KAKAN on Jun 30, 2016, 04:08 PM
Quote from: Hercules on Jun 30, 2016, 03:58 PMIn lms    hercules   
in spawnwep  and spawnloc tables written in different cases like [RR]HeRcUlEs
that's the problem
any solution @Mashreq @KAKAN

KAKAN

use SQL's LOWER( whatever it is :p )
oh no

Cool

Quote from: KAKAN on Jun 30, 2016, 04:19 PMuse SQL's LOWER( whatever it is :p )
but then why its works when player is online

Xmair

@KAKAN, it's
lower( something )
@Hercules, try using collate nocase.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Cool

#12
Quote from: Xmair on Jun 30, 2016, 05:05 PM@KAKAN, it's
lower( something )
@Hercules, try using collate nocase.
Thanks @KAKAN @Xmair @Mashreq  for help now my all queries working but lms not working but i think i will solve it thanks for fixing big bug. :D