SA-MP Forums Archive
dialog only loads the first integer - 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: dialog only loads the first integer (/showthread.php?tid=608107)



dialog only loads the first integer - justjamie - 27.05.2016

Hello.
i have this code, and it only loads the first one.
How can i make it work?
command:
PHP код:
COMMAND:temp(playerid,params[])
{
new 
query[420];
format(query,sizeof(query),"SELECT * FROM vehicles WHERE owner='%s'",PlayerName(playerid));
mysql_function_query(dbhandle,query,true,"OnCarSpawnCommand","i",playerid);
return 
1;

function
PHP код:
forward OnCarSpawnCommand(playerid);
public 
OnCarSpawnCommand(playerid)
{
new 
num_fields2,num_rows2;
new
    
string  500 ],
    
string1337[420],
    
temp_carowner[35];
cache_get_data(num_rows2,num_fields2,dbhandle);
if(
num_rows2!=0)
{
for(new 
0sizeof(num_rows2); v++)
{
  
cache_get_field_content(v"owner"temp_carowner);
  
format(string1337,sizeof(string1337),"%s",temp_carowner);
  
myStrcpy(cInfo[v][carowner], string1337);
  
 if(!
strcmp(cInfo[v][carowner], PlayerName(playerid), false))
 {
    
format(stringsizeof(string), "%i (%i)\n"cache_get_field_content_int(v,"model",dbhandle),cache_get_field_content_int(v,"id",dbhandle));
 }
 else
 {
 return 
1;
 }
}
}
ShowPlayerDialog(playerid,DIALOG_CARSPAWN,DIALOG_STYLE_LIST,"Car spawning",string,"Spawn","Close");
return 
1;




Re: dialog only loads the first integer - justjamie - 27.05.2016

Someone?


Re: dialog only loads the first integer - Stinged - 27.05.2016

Even though the rules say you can only bump after 24 hours, I'd still understand if someone bumps their topic after 12 hours, but after only 17 minutes...?


Re: dialog only loads the first integer - justjamie - 27.05.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Even though the rules say you can only bump after 24 hours, I'd still understand if someone bumps their topic after 12 hours, but after only 17 minutes...?
Sorry xd i just really wanna fix this so i can move on with my script xd.


Re: dialog only loads the first integer - dicknyson - 27.05.2016

Quote:

for(new v = 0; v < sizeof(num_rows2); v++)

You're making "v" increment if it's less than the string length of "num_rows2". You need to change it to:

Код:
for(new v = 0; v < num_rows2; v++)



Re: dialog only loads the first integer - justjamie - 28.05.2016

Quote:
Originally Posted by dicknyson
Посмотреть сообщение
You're making "v" increment if it's less than the string length of "num_rows2". You need to change it to:

Код:
for(new v = 0; v < num_rows2; v++)
you're right xd.
it still only reads the first integer tho


Re: dialog only loads the first integer - Stinged - 28.05.2016

Код:
COMMAND:temp(playerid, params[])
{
	new query[62];
	GetPlayerName(playerid, query, 24);
	format(query, sizeof(query), "SELECT * FROM vehicles WHERE owner='%s'", query);
	mysql_function_query(dbhandle, query, true, "OnCarSpawnCommand", "i", playerid);
	return 1; 
}

forward OnCarSpawnCommand(playerid);
public OnCarSpawnCommand(playerid)
{
	new
		rows, fields;
	cache_get_data(rows, fields, dbhandle);
	
	if (rows)
	{
		new str[512];
		for (new v = 0; v < rows; v++)
		{ 
			format(str, sizeof(str), "%s%i (%i)\n", str, cache_get_field_content_int(v, "model", dbhandle), cache_get_field_content_int(v, "id", dbhandle));
		}
		ShowPlayerDialog(playerid, DIALOG_CARSPAWN, DIALOG_STYLE_LIST, "Car spawning", str, "Spawn", "Close");
		return 1;
	}
	SendClientMessage(playerid, 0xFF0000FF, "Could not find anything in the database.");
	return 1; 
}