Hi everyone, sorry my english is not good.
I'm having trouble with CreateActor.
I am doing a test that I will put an Actor in any position along with Checkpoint as the location of the Actor. When I go to Checkpoint, I will use DestroyActor then CreateActor in the next location. And so I repeated, and I realized that sometimes Actor was not created but only Checkpoint. It just does not appear at all. I want to ask is why?
Код:
new pactor[MAX_PLAYERS];
new cpoint[MAX_PLAYERS];
new Float:PosActor[4][4] =
{
{1464.30004883, -725.00000000, 92.50000000, 290.00000000},
{634.90002441, -1111.09997559, 46.50000000, 219.99511719},
{-2697.69995117, -130.50000000, 4.09999990, 270.00000000},
{-2648.60009766, 166.60000610, 4.09999990, 0.00000000}
}
CMD:setactor(playerid, params[])
{
if(IsValidActor(pactor[playerid])) DestroyActor(pactor[playerid]);
new rand = random(3);
pactor[playerid] = CreateActor(1, PosActor[rand][0], PosActor[rand][1], PosActor[rand][2], PosActor[rand][3]);
cpoint[playerid] = 1;
SetPlayerCheckpoint(playerid, PosActor[rand][0], PosActor[rand][1], PosActor[rand][2], 3.0);
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(cpoint[playerid] != 0)
{
if(IsValidActor(pactor[playerid])) DestroyActor(pactor[playerid]);
new rand = random(3);
pactor[playerid] = CreateActor(1, PosActor[rand][0], PosActor[rand][1], PosActor[rand][2], PosActor[rand][3]);
cpoint[playerid] = 1;
SetPlayerCheckpoint(playerid, PosActor[rand][0], PosActor[rand][1], PosActor[rand][2], 3.0);
}
return 1;
}
Your code seems correct, try to debug it by printing step by step what your code is doing.