Mysql Registrate
#1

Hello need help with sql registration system :

this is my registrate dialog :

Код:
if(dialogid == DIALOG_REGISTER) //REGISTRACIJA
	{
			if(!response) Kick(playerid);
			if(strlen(inputtext)>=5)
			{
			new query[300];
            //WP_Hash(PlayerInfo[playerid][Password], 129, inputtext); //hashing inputtext
            mysql_format(sqlconnect, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `posX` ,`posY`, `posZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 1788.6445,-1601.3077,13.5469)", Name[playerid], inputtext, IP[playerid]);
            mysql_tquery(sqlconnect, query, "OnAccountRegister", "i", playerid);
			
			
			}
			else
			{
			        //Slaptazodis per trumpas
				SendClientMessage(playerid,COLOR_RED,"Jusu Slaptazodis per trumpas ");
                ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registracija","Iveskite slaptazodi:","Registruotis","Iseiti");
			}
When i registrate he dost give my any error or something do everything whats he needs to do excepts player position , when i complete registration and press spawn its doasnt put my at the location i put in mysql
but give some random location like on this picture :


this is my spawn, and disconnect call backs :

Код:
public OnPlayerSpawn(playerid)
{
    
    
    
	SetPlayerFacingAngle(playerid,	169.2070 );
	SetPlayerPos(playerid, PlayerInfo[playerid][posX], PlayerInfo[playerid][posZ], PlayerInfo[playerid][posZ]);
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new query[128], Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    mysql_format(sqlconnect, query, sizeof(query), "UPDATE `accounts` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f WHERE `ID`=%d",\
    PlayerInfo[playerid][Admin], PlayerInfo[playerid][Vip], PlayerInfo[playerid][Money], pos[0], pos[1], pos[2], PlayerInfo[playerid][ID]);
    mysql_tquery(sqlconnect, query, "", "");
    


	return 1;
}
those both are working aswell after i register then relog they give my position like i was before update is working but insert position not working or it insert wrong possition cord
this is how look my db after registration :


who can help my to make it work
Reply
#2

So where do you actually assign a value to PlayerInfo[playerid][posX/Y/Z] after the registration is complete? Nowhere, it seems.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
So where do you actually assign a value to PlayerInfo[playerid][posX/Y/Z] after the registration is complete? Nowhere, it seems.
Код:
public OnAccountLoad(playerid)
{

    PlayerInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin"); 
    PlayerInfo[playerid][Vip] = cache_get_field_content_int(0, "Vip"); 
    PlayerInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
    PlayerInfo[playerid][posX] = cache_get_field_content_float(0, "posX");
    PlayerInfo[playerid][posY] = cache_get_field_content_float(0, "posY");
    PlayerInfo[playerid][posZ] = cache_get_field_content_float(0, "posZ");

    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
    SendClientMessage(playerid, -1, "Sekmingai prisijungete"); 



return 1;
}
i did everything like on this tut https://sampforum.blast.hk/showthread.php?tid=485633

almost copy paste just take off wp_hash cuz with him i got some sql error
i have some npc on my server not sure maybe they couse some problems ? and before i do registration stuff my npcs works perfect after registration they get same stuff like my get in random position on spawn usualy underground
Reply
#4

I see no reference to that function in any of the code you posted above. I only see "OnAccountRegister".
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
I see no reference to that function in any of the code you posted above. I only see "OnAccountRegister".
that function is for login to get data ,
and hare is on account registered :
Код:
public OnAccountRegister(playerid)
{
    SendClientMessage(playerid, -1, "Sekmingai uzsiregistravote");
    PlayerInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("Sekmingai uzsiregistravote. ID: %d", PlayerInfo[playerid][ID]); //just for debugging.
    return 1;
}
the thing is u are probably sow that tut already , and know how its works if not i will tell u : its give u registration dialog ware u insert all information and position registration part done , then on account load when u are connecting script will get data from db and thos pos u are inserted in ,then on playerspawn they use those cords and should set u there but it wont work
Reply
#6

Solved tnx to kreison , was to small update query
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)