PDA

View Full Version : MySQL Username problem


NegativeCZE
07/10/2017, 01:29 PM
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,D LX,DLY,DLOn,MRows,MX,MY,MOn,Spawn,SpawnTime,IP,Dyn amic,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),SkinyP ovolani[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 :-)

Jstylezzz
07/10/2017, 02:40 PM
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.

NegativeCZE
08/10/2017, 11:02 AM
Yeah, thats the problem. Thank you man, you fixed it. :-P

Thank you very much. :-) (+rep)