MySQL Username problem
#1

Hello, my friend sent me a folder where he gathered some old gamemodes and other things. I decided to make some work for myself and I would test them on a private server. But I have a problem. One game mode requires a MySQL connection. So, I've created tables into which data will be written. But the table named "Username" will be written 0.

(Im sorry for my bad English, but i tried to get help in my own language forum, but with no result... )

To better understand i attach some screenshots..

Code:
Код:
public OnPlayerRequestSpawn(playerid)
{
//==================================( F4 )======================================
    if(NejblizsiNemocnice[playerid] != -1) SpawnPlayer(playerid);
//================================( Spawn )=====================================
    if(StranaObchodu[playerid] != -1 && !Spawnuty[playerid])
    {
		new query[340], PIP[16], Dynamic[45], pass[MAX_DELKA_HESLA], LokalitaID = DialogListitem[playerid], time = gettime();
		GetPlayerIp(playerid,PIP,sizeof(PIP));
		gpci(playerid,Dynamic,sizeof(Dynamic));
		GetPVarString(playerid,"Heslo",pass,sizeof(pass));
		DeletePVar(playerid,"Heslo");
		format(query,sizeof(query),"INSERT INTO ucty3(Username,Heslo,Penize,Skin,XS,YS,ZS,DLRows,DLX,DLY,DLOn,MRows,MX,MY,MOn,Spawn,SpawnTime,IP,Dynamic,Log) VALUES ('%s',%d,12000,%d,%f,%f,%f,3,608,122,1,5,608,155,1,%d,%d,'%s','%s',%d)",PlayerName(playerid),ZahashovatHeslo(pass),SkinyPovolani[IntervalySkinuPovolani[NEZAMESTNANY]+random(IntervalySkinuPovolani[NEZAMESTNANY+1]-IntervalySkinuPovolani[NEZAMESTNANY])],SouradniceSpawnu[LokalitaID][0],SouradniceSpawnu[LokalitaID][1],
		SouradniceSpawnu[LokalitaID][2]+0.5,LokalitaID,time,PIP,Dynamic,time);
		mysql_q(query,false);
		format(query,sizeof(query),"SELECT * FROM ucty3 WHERE Username='%s'",PlayerName(playerid));
		new Cache:cache = mysql_q(query);
		if(cache_num_rows())
		{
			for(new PTextDraw=Obchod_Strana;PTextDraw<Obchod_Strana+7;PTextDraw++) PlayerTextDrawDestroy(playerid,PlayerTextdraw[playerid][PTextDraw]);
		    NahratUdaje(playerid,cache);
			NovyHrac[playerid] = true;
			UkazatHraciStranuTutorialu(playerid,0);
			//for(new pos;pos<3;pos++) PoziceHraceTutorial[playerid][pos] = SouradniceSpawnu[LokalitaID][pos];
		}
		else cache_delete(cache);
    }
	return 0;
}
//______________________________________________________________________________
The " PlayerName(playerid) " i have stocked on top.
Code:
Код:
stock PlayerName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	return name;
}
Simplified problem: It creates 1 thing in the table, and other players are not created. ( There is only one account for all players - you can see in screenshot)

Thanks for help
Reply
#2

From the screenshot it looks as if all your fields are of type INT. Can you verify that username and password are VARCHAR/TEXT, and that your location fields (XS, YS, ZS) are FLOAT/DECIMAL? If you're not sure, post a screenshot of your structure so we can see the types you set.
Reply
#3

Yeah, thats the problem. Thank you man, you fixed it.

Thank you very much. (+rep)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)