SA-MP Forums Archive
CreateDynamicObject not creating object - 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: CreateDynamicObject not creating object (/showthread.php?tid=547641)



CreateDynamicObject not creating object - Jonesy96 - 23.11.2014

Hi all. I'm currently creating a roadblock command using OnPlayerModelSelection. For some reason though, the object is not added when selected. Below is the code. Any help would be appreciated!

Код:
new roadblocklist[10]={2892, 2899, 973,1424,1425,1427,1459,4508,1422,1423};
new activeroadblocks[20];
Код:
CMD:roadblock(playerid, params[]){
//PD ONLY
	if(pData[playerid][PdDuty] != 1) return SendClientMessage(playerid, COLOR_ERROR_RED, "You are not on duty!");
	ShowModelSelectionMenuEx(playerid, roadblocklist, sizeof(roadblocklist), "Select Roadblock", DIALOG_PD_ROADBLOCK, 16.0, 0.0, -55.0);
	return 1;
}
Код:
public OnPlayerModelSelection(playerid, response, listid, modelid)
{
	if(listid == DIALOG_PD_ROADBLOCK){
		if(response){
			for(new i=0; i < sizeof(activeroadblocks); i++){
				if(activeroadblocks[i] == 0){
					new Float:x, Float:y, Float:z, Float:angle;
					GetPlayerPos(playerid, x, y, z);
					GetPlayerFacingAngle(playerid,angle);
					activeroadblocks[i] = CreateDynamicObject(modelid, x, y, z-0.9, 0, 0, angle);
					SendClientMessage(playerid, COLOR_LIGHTBLUE, "You placed down a roadblock!");
					break;
				}else if(i == sizeof(activeroadblocks) - 1){
					SendClientMessage(playerid, COLOR_ERROR_RED, "There are already 20 roadblocks active. Please delete one first!");
				}
			}
		}
	}
    return 1;
}



Re: CreateDynamicObject not creating object - AlphaPac - 24.11.2014

You need to be using:

pawn Код:
OnPlayerModelSelectionEx
as you used:
pawn Код:
ShowModelSelectionMenuEx



Re: CreateDynamicObject not creating object - Jonesy96 - 24.11.2014

Fixed. Using the wrong callback. Silly me.