[MSQL] It doesn't give me any money when i login.
#1

Hello, im still new to MSQL, and when i login it should give me money, because in Database it says that i have 1000$, but it doesn't give me the money in game, and i don't get what the problem is... Here's the Script:

Код:
if(dialogid == 200)
	{
	    if(response)
	    {
	        new vardas[MAX_PLAYER_NAME];
	        GetPlayerName(playerid, vardas, sizeof(vardas));
	        new query[ 128 ], EscapedPass[ 128 ];
	        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"{A3E4FF}Prisijungimas","{FFFFFF}Jus neivedete slaptazodzio.\n{FFFFFF}Prasome ivesti slaptazodi, kad galetumete prisijungti.","Prisijungti","Atsaukti");
	        if(strlen(inputtext) < 3 || strlen(inputtext) >= 32)
	    	return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"{A3E4FF}Prisijungimas","{FFFFFF}Slaptazodis yra per trumpas arba per ilgas.\n{FFFFFF}Prasome ivesti teisinga slaptazodi, kad galetumete prisijungti!","Prisijungti","Atsaukti");
        	mysql_real_escape_string( inputtext, EscapedPass );
        	format(query,sizeof(query), "SELECT * FROM `Saskaitos` WHERE `Vardas` = '%s' AND `Slaptazodis` = '%s'", vardas, EscapedPass );
        	mysql_query( query );
       		mysql_store_result();

        	if( mysql_num_rows() >= 1 )
        	{
          	    prisijunges[playerid] = 1;
				SendClientMessage(playerid, geltona, "[FunZoneLT]>> Jus prisijungete! Sekmes zaidime jums linki Administracijos komanda!");
				GivePlayerMoney(playerid, -50000);
				if(ALygis[playerid] >= 1)
  				{
  		    		Alabel[playerid] = Create3DTextLabel("Administratorius", raudona,30.0,40.0,50.0,40.0,0);
    				Attach3DTextLabelToPlayer(Alabel[playerid], playerid, 0.0, 0.0, 0.7);
				}
        	}
        	else
        	{
                ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"{A3E4FF}Prisijungimas","{FFFFFF}Jus ivedete neteisinga slaptazodi.\n{FFFFFF}Prasome ivesti teisinga slaptazodi, kad galetumete prisijungti!","Prisijungti","Atsaukti");
        	}
        	mysql_free_result();
        	new row[128];
			new field[7][32];
			mysql_fetch_row_format(row, "|");
			explode(row, field, "|");
			mysql_free_result();
			format(ZStats[playerid][Slaptazodis], 32, "%s", field[1]);
 			ZStats[playerid][Adminas] = strval(field[3]);
 			ZStats[playerid][Pinigai] = strval(field[4]);
 			GivePlayerMoney(playerid, ZStats[playerid][Pinigai]); // this is where it should give me, the money...
 			CheckMySQL();
		}
		else
		{
		    SendClientMessage(playerid, raudona, "[FunZoneLT]>> Jus turite prisijungti prie serverio, pries zaidziant!");
		    Kick(playerid);
		}
	}
Please help me.
Reply
#2

Use print to check the values in each field. You must remember that field[4] is a string, not a integer so use strval to turn it into a integer.
Reply
#3

Could you give me a example? Because now im lost..
Reply
#4

For your sake, just use sscanf instead of explode.
Reply
#5

GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)