SA-MP Forums Archive
mysql rename not working properly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql rename not working properly (/showthread.php?tid=549730)



mysql rename not working properly - kampuman - 08.12.2014

I have the following codes below, but I wonder why it only creates another account and when it creates a new account, all the stats were gone. Need help!

Код:
	if(dialogid == DIALOG_RENAME)
	{
	    if(!response)
		{
			ShowLoginScreen(playerid);
		}
		if(response)
		{
		    if(strlen(inputtext) < 4)
		    {
		          SendClientMessage(playerid, -1, ""RED"[PASS] "WHITE"Please enter a username GREATER than 3 characters.");
		          ShowRenameScreen(playerid);
		    }
			  new Query[100];
			  format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Name` = '%s'",inputtext);
			  mysql_function_query(cHandle, Query, true, "RenamePlayer", "ds", playerid, inputtext);
		}
	}
Код:
public RenamePlayer(playerid,name[])
{
    new rows, fields;
    cache_get_data(rows, fields, cHandle);
    if(rows)
    {
		SendClientMessageEx(playerid,-1,""RED"[RENAME] "WHITE"The username %s is already exists in the database, please try another username.", name);
		ShowLoginScreen(playerid);
		return 1;
	}
	SetPlayerName(playerid, name);
	ShowRegisterScreen(playerid);
	SendClientMessageEx(playerid,-1,""RED"[RENAME] "GREEN"You have successfully changed your name to %s", name);
	return 1;
	
}



Re: mysql rename not working properly - Raweresh - 08.12.2014

There is not code for creating account. Maybe show function ShowRegisterScreen.


Re: mysql rename not working properly - kampuman - 08.12.2014

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
There is not code for creating account. Maybe show function ShowRegisterScreen.
Well, im guessing that the code I gave is only for creating another account but not renaming?

Код:
public ShowRegisterScreen(playerid)
{
    new string[300];
	format(string, sizeof(string), "{FFFFFF}Welcome to {00CC66}E{FFFFFF}nchanted {00CC66}L{FFFFFF}and {00CC66}F{FFFFFF}reeroam{00CC66}!{FFFFFF}\n\nType your desired password here to register a new account {FFD700} \n\nNOTE:\n {FFFFFF}- Your password should have atleast 4 characters \n - Never give out your password to anyone");
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00CC66}Account Registration", string, "Register", "Leave");
    return 1;
}
thanks for helping me again.