SA-MP Forums Archive
Command doesn't work - 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: Command doesn't work (/showthread.php?tid=608088)



Command doesn't work - justjamie - 27.05.2016

Hello.
When i enter this command ingame, nothing happends.
Did i miss something?
PHP код:
COMMAND:temp(playerid,params[])
{
    for(new 
v=0PlayerInfo[playerid][amountofcars]; v++)
    {
    new 
string[420];
    
format(string,sizeof(string),"%i(%i)",cInfo[v][carmodelid],cInfo[v][db_id]);
    
ShowPlayerDialog(playerid,DIALOG_CARSPAWN,DIALOG_STYLE_LIST,"Car spawning",string,"Spawn","Close");
    }
    return 
1;




Re: Command doesn't work - Darkwood17 - 27.05.2016

Код:
COMMAND:temp(playerid,params[])
{
	new string[420];
	for(new v=0; v < PlayerInfo[playerid][amountofcars]; v++)
	{
		format(string, sizeof(string), "%i(%i)", cInfo[v][carmodelid], cInfo[v][db_id]);
	}
	ShowPlayerDialog(playerid, DIALOG_CARSPAWN, DIALOG_STYLE_LIST, "Car spawning", string, "Spawn", "Close");
	return 1;
}
ShowPlayerDialog() should be out of the loop.


Re: Command doesn't work - justjamie - 27.05.2016

Quote:
Originally Posted by Darkwood17
Посмотреть сообщение
Код:
COMMAND:temp(playerid,params[])
{
	new string[420];
	for(new v=0; v < PlayerInfo[playerid][amountofcars]; v++)
	{
		format(string, sizeof(string), "%i(%i)", cInfo[v][carmodelid], cInfo[v][db_id]);
	}
	ShowPlayerDialog(playerid, DIALOG_CARSPAWN, DIALOG_STYLE_LIST, "Car spawning", string, "Spawn", "Close");
	return 1;
}
ShowPlayerDialog() should be out of the loop.
welp still nothing when i run the command


Re: Command doesn't work - Dayrion - 27.05.2016

This even not show the Dialog ? Are you sure PlayerInfo[playerid][amountofcars] is valid?


Re: Command doesn't work - justjamie - 27.05.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
This even not show the Dialog ? Are you sure PlayerInfo[playerid][amountofcars] is valid?
Indeed, it doesn't show the dialog.
this is where PlayerInfo[playerid][amountofcars] is getting loaded:
PHP код:
forward ToLoadCars(playerid);
public 
ToLoadCars(playerid)
{
new 
num_fields2,num_rows2;
cache_get_data(num_rows2,num_fields2,dbhandle);
if(
num_rows2==1)
{
for(new 
0sizeof(num_rows2); i++)
{
new 
temp_carowner[35],string[50],temp_plate[60],string2[60];
cInfo[i][db_id]=cache_get_field_content_int(0,"id",dbhandle);
cInfo[i][carmodelid]=cache_get_field_content_int(0,"model",dbhandle);
cInfo[i][c_x]=cache_get_field_content_float(0,"x",dbhandle);
cInfo[i][c_y]=cache_get_field_content_float(0,"y",dbhandle);
cInfo[i][c_z]=cache_get_field_content_float(0,"z",dbhandle);
cInfo[i][c_r]=cache_get_field_content_float(0,"a",dbhandle);
cInfo[i][c_color1]=cache_get_field_content_int(0,"color1",dbhandle);
cInfo[i][c_color2]=cache_get_field_content_int(0,"color2",dbhandle);
cInfo[i][c_respawntime]=cache_get_field_content_int(0,"autorespawn",dbhandle);
cInfo[i][carteam]=cache_get_field_content_int(0,"carteam",dbhandle);
PlayerInfo[playerid][amountofcars]=num_rows2;
        
cache_get_field_content(0"owner"temp_carowner);
        
format(string,sizeof(string),"%s",temp_carowner);
        
myStrcpy(cInfo[i][carowner], string);
        
cache_get_field_content(0"plate"temp_plate);
        
format(string2,sizeof(string2),"%s",temp_plate);
        
myStrcpy(cInfo[i][plate], string2);
}
return 
1;
}
else
{
return 
1;
}

Whenever you login, this gets run.