help create 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: help create object (
/showthread.php?tid=463073)
help create object -
BecksLennon - 10.09.2013
pawn Код:
CMD:createo(playerid, params[])
{
new i;
for(i=0; i < MAX_OBJECTS_PP; i++)
{
if(oData[playerid][objID][i] == -1) break;
if(i == ( MAX_OBJECTS_PP -1 ) ) return SendClientMessage(playerid, red, "You can't create more objects..");
}
new objectid;
if(sscanf(params, "i", objectid)) return SendClientMessage(playerid, -1, "USAGE: /createo [model id]");
new Float:pos[4];
oData[playerid][objID][i] = objectid;
oData[playerid][slotobjID] = i;
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
pos[0] += (3 * floatsin(-pos[3], degrees));
pos[1] += (3 * floatcos(-pos[3], degrees));
CreateObject(objectid, pos[0], pos[1], pos[2], 0.0, 0.0, pos[3]);
format(ssstring, SOS, "-OBJECT- MODELID: %d, SLOT ID: %d, X:%0.2f,Y:%0.2f,Z:%0.2f", objectid, oData[playerid][slotobjID], pos[0], pos[1], pos[2]);
SendClientMessage(playerid, YELLOW, ssstring);
return 1;
}
CMD:deleteo(playerid, params[])
{
new slot;
oData[playerid][slotobjID] = slot;
if(sscanf(params, "i", slot)) return SendClientMessage(playerid, red, "USAGE: /deleteo [slot id]");
DestroyObject(oData[playerid][objID][slot] );
return 1;
}
Everything seems fine, assigns the id and everything but when giving / deleteo [slot] does not delete the object, it will be ..?
here the enum and the variable that stores the slot is supposed
pawn Код:
#define MAX_OBJECTS_PP 50
enum oInfo
{
objID[MAX_OBJECTS_PP],
slotobjID
}
new oData[MAX_PLAYERS][oInfo];
Re: help create object -
Eyce - 10.09.2013
Assign the object to your variable so that
DestroyObject would work.
pawn Код:
oData[playerid][objID][i] = CreateObject(...);
Respuesta: help create object -
BecksLennon - 10.09.2013
pawn Код:
CMD:deleteo(playerid, params[])
{
new slot;
oData[playerid][slotobjID] = slot;
oData[playerid][objID][i] = CreateObject(...);
if(sscanf(params, "i", slot)) return SendClientMessage(playerid, red, "USAGE: /deleteo [slot id]");
DestroyObject(oData[playerid][objID][slot] );
return 1;
}
well, if you can explain rather
Re: help create object -
Eyce - 10.09.2013
pawn Код:
enum oInfo
{
objID[MAX_OBJECTS_PP],
slotobjID
}
new oData[MAX_PLAYERS][oInfo];
new oObjectID[MAX_PLAYERS][MAX_OBJECTS_PP]; // add this
Then change
pawn Код:
CreateObject(objectid, pos[0], pos[1], pos[2], 0.0, 0.0, pos[3]);
to
pawn Код:
oObjectID[playerid][i] = CreateObject(objectid, pos[0], pos[1], pos[2], 0.0, 0.0, pos[3]);
When you delete the object, use this:
pawn Код:
DestroyObject(oObjectID[playerid][slot]);