[HELP]DestroyPlayerObject
#1

Hey, I'm trying to create an object for any player that is not admin level 5+ when he spawns and to delete it if he is (when he spawns), its the first time I'm using player objects and I really didn't know how this works, I tried to do this my way;

Код HTML:
	new hadalwall;
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(PlayerInfo[i][pAdmin] < 5)
		{
     		DestroyPlayerObject(i, hadalwall);
			hadalwall = CreatePlayerObject(i,2395, 548.61, 2567.65, 348.70,   0.00, 270.00, 180.00);
		}
		else if(PlayerInfo[i][pAdmin] >= 5)
		{
			DestroyPlayerObject(i, hadalwall);
		}
	}
And I tried another way after searching online and it still didn't work;

Код HTML:
	new hadalwall[MAX_PLAYERS];
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(PlayerInfo[i][pAdmin] < 5)
		{
     		DestroyPlayerObject(i, hadalwall[playerid]);
			hadalwall[i] = CreatePlayerObject(i,2395, 548.61, 2567.65, 348.70,   0.00, 270.00, 180.00);
		}
		else if(PlayerInfo[i][pAdmin] >= 5)
		{
			DestroyPlayerObject(i, hadalwall[playerid]);
		}
	}
It created the object if the player is not a level 5+ admin, but it does not destroy it when he spawns again as a level 5 administrator. HELP please.
Reply
#2

pawn Код:
new hadalwall[MAX_PLAYERS];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] < 5)
        {
                hadalwall[i] = CreatePlayerObject(i,2395, 548.61, 2567.65, 348.70,   0.00, 270.00, 180.00);
        }
    }
If the player's level is below 5, the object is being created, if he's 5 or above, it's not. No need to first create it and then destroy it again.
Reply
#3

Yeah okay, but I did this for a reason, I want it so if I promote someone to a level five admin, it will automatically update it when he spawns and he'll be able to do what he can't if the object is still there.

Plus, if I won't add DestroyPlayerObject before it creates it, the object will be created everytime the player spawn.
Reply
#4

pawn Код:
new hadalwall[MAX_PLAYERS];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] < 5)
        {
                hadalwall[i] = CreatePlayerObject(i,2395, 548.61, 2567.65, 348.70,   0.00, 270.00, 180.00);
        }
                if(PlayerInfo[i][pAdmin] >= 5)
                {
                        if(IsValidPlayerObject(playerid,hadalwall[i])
                        {
                            DestroyPlayerObject(playerid,hadalwall[i])
                        }
                }
    }
Reply
#5

It still do not destroy the object when I spawn back again as a level 5 admin :\
Reply
#6

You mean when you promote a player ingame?
Then put this into the piece of code where you promote the player:
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 5)
{
    if(IsValidPlayerObject(playerid,hadalwall[playerid])
    {
        DestroyPlayerObject(playerid,hadalwall[playerid]);
    }
}
If the player you promoted is level 5 and above and the playerobject hadalwall is created it's been destroyed for the player.

Also, under which callback did you have the original code you showed?
Reply
#7

1. Thanks, I'll try.
2. OnPlayerSpawn and I did re-spawn every time to check it works and it didnt.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)