problem with DestroyPlayerObject -
ratxrat - 17.02.2016
i create playerobject this my code
PHP код:
new kardus; //global variable
forward proseskemas // timer
public proseskemas(playerid)
{
kardus = CreateObject(3013, 0.0,0.0, 0.0, 0.00000, 0.00000, 0.00000);
AttachObjectToPlayer(kardus,playerid,-0.00780, 0.41076, 0.30842, 0.00000, 0.00000, 0.00000);
TogglePlayerControllable(playerid, true);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_CARRY);
AttachObjectToPlayer(kardus,playerid,-0.00780, 0.41076, 0.30842, 0.00000, 0.00000, 0.00000);
PlayerInfo[playerid][pkemas] = 0;
PlayerInfo[playerid][pjadi] = 1;
SendClientMessage(playerid, PURPLE, "proses selesai simpan di tempat jadi \n gunakan /simpanjadi");
}
CMD:prosesmentah(playerid, params[])
{
if (PlayerInfo[playerid][pFaction] == 3)
{
if(IsPlayerInRangeOfPoint(playerid, 8.0, 2489.1372,-2547.9502,9979.3379 ) || IsPlayerInRangeOfPoint(playerid, 8.0, 2483.7302,-2548.0552,9979.3379 ) || IsPlayerInRangeOfPoint(playerid, 8.0, 2477.1328,-2546.0029,9979.3379 ))
{
if (PlayerInfo[playerid][pmentah] == 1)
{
TogglePlayerControllable(playerid, 0);
SetTimerEx("proseskemas", 10000, false, "i", playerid); // called timmer
SetCameraBehindPlayer(playerid);
}
else SendClientMessage(playerid, COLOR_RED, "Kamu tidak punya bahan mentah ambil dulu di penyimpanan");
}
else SendClientMessage(playerid, COLOR_RED, "Kamu tidak di tempat pengolahan");
}
else SendClientMessage(playerid, COLOR_RED, "Kamu bukan pekerja pabrik");
return 1;
}
then i DestroyPlayerObject with this command
PHP код:
CMD:simpanjadi(playerid, params[])
{
if (PlayerInfo[playerid][pFaction] == 3)
{
if(IsPlayerInRangeOfPoint(playerid, 8.0,2464.3308,-2537.2014,9979.3379))
{
if (PlayerInfo[playerid][pjadi] == 1)
{
DestroyPlayerObject(playerid,kardus); // this destroyplayerobject
jadi += 1;
PlayerInfo[playerid][pjadi] = 0 ;
SetPlayerSpecialAction(playerid,0);
new jaaad[128];
format(jaaad, sizeof(jaaad), "bahan mentah tersedia %d/10000", jadi);
UpdateDynamic3DTextLabelText(jaditext, whijau, jaaad);
SendClientMessage(playerid, whijau, "bahan telah di simpan");
}
else
SendClientMessage(playerid, COLOR_RED, "Kamu tidak punya bahan jadi untuk disimpan");
}
else
SendClientMessage(playerid, COLOR_RED, "Kamu tidak di tempat bahan jadi");
}
else
SendClientMessage(playerid, COLOR_RED, "Kamu bukan pegawai pabrik");
return 1;
}
object cannot destroy how to destroyplayerobject ??
Re: problem with DestroyPlayerObject -
ratxrat - 17.02.2016
Re: problem with DestroyPlayerObject -
ratxrat - 17.02.2016
----
Re: problem with DestroyPlayerObject -
Sew_Sumi - 17.02.2016
You're using CreateObject then DestroyPlayerObject... They're not related.
Use DestroyObject.
However, your code is going to run into problems. If more than one person uses this command, (In it's current state) it will lock the players object and won't destroy the first created object.
It's because this code only puts out one variable. Where you should use an array, set to MAX_PLAYERS, and use the playerid to specify that the players object e.g. DestroyObject(kardus[playerid]);