Little help with OnPlayerEnterDynamicCP
#1

Hey, i made a /collectgarbage command for Garbage man job, it creates a Dynamic CP defined as GarbageCheckpoint1 when player enter it it should create another checkpoint. But when i entered the checkpoint nothing happened. i think that there might be a problem with My OnPlayerEnterDynamicCP callback.

here it is

Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
	if(checkpointid == GarbageCheckpoint1)
	{
		new string[128];
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0,0,0,0,0,0);
        GarbageCheckpoint2 = CreateDynamicCP(-349.1976,1544.5193,75.5625, -1, -1, playerid);
        SendClientMessage(playerid, GREEN, "Go to next checkpoint.");
        format(string, sizeof(string), "%s collects some garbage and puts them in his plastic bag.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
	}
	if(checkpointid == GarbageCheckpoint2)
	{
		new string[128];
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0,0,0,0,0,0);
        GarbageCheckpoint3 = CreateDynamicCP(-361.4394,1572.8923,75.9229, -1, -1, playerid);
        SendClientMessage(playerid, GREEN, "Go to next checkpoint.");
        format(string, sizeof(string), "%s collects some garbage and puts them in his plastic bag.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
	}
	if(checkpointid == GarbageCheckpoint3)
	{
		new string[128];
        ApplyAnimation(playerid, "DEALER", "DEALER_DEAL", 4.0,0,0,0,0,0);
        SendClientMessage(playerid, GREEN, "You have finished your work.");
        format(string, sizeof(string), "%s puts the plastic bag inside the garbage bin.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
        PlayerStat[playerid][CollectingGarbage] = 0;
        PlayerStat[playerid][AbleToCollectGarbage] = 0;
		JobID1ReloadTimer = SetTimer("JobID1ReloadTime", 60000, false);
	}
	return 1;
}
Thanks for helping.
Reply
#2

OnGameModeInit
pawn Код:
GarbageCheckpoint1 = CreateDynamicCP(/* coords */, 2.0);
GarbageCheckpoint2 = CreateDynamicCP(-349.1976,1544.5193,75.5625, 2.0);
GarbageCheckpoint3 = CreateDynamicCP(-361.4394,1572.8923,75.9229, 2.0);
OnPlayerConnect
pawn Код:
TogglePlayerDynamicCP(playerid, GarbageCheckpoint1, 0);
TogglePlayerDynamicCP(playerid, GarbageCheckpoint2, 0);
TogglePlayerDynamicCP(playerid, GarbageCheckpoint3, 0);
/collectgarbage
pawn Код:
TogglePlayerDynamicCP(playerid, GarbageCheckpoint1, 1);
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == GarbageCheckpoint1)
    {
        new string[128];
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0,0,0,0,0,0);
        TogglePlayerDynamicCP(playerid, GarbageCheckpoint1, 0);
        TogglePlayerDynamicCP(playerid, GarbageCheckpoint2, 1);
        SendClientMessage(playerid, GREEN, "Go to next checkpoint.");
        format(string, sizeof(string), "%s collects some garbage and puts them in his plastic bag.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
    }
    else if(checkpointid == GarbageCheckpoint2)
    {
        new string[128];
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0,0,0,0,0,0);
        TogglePlayerDynamicCP(playerid, GarbageCheckpoint2, 0);
        TogglePlayerDynamicCP(playerid, GarbageCheckpoint3, 1);
        SendClientMessage(playerid, GREEN, "Go to next checkpoint.");
        format(string, sizeof(string), "%s collects some garbage and puts them in his plastic bag.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
    }
    else if(checkpointid == GarbageCheckpoint3)
    {
        new string[128];
        ApplyAnimation(playerid, "DEALER", "DEALER_DEAL", 4.0,0,0,0,0,0);
        TogglePlayerDynamicCP(playerid, GarbageCheckpoint3, 0);
        SendClientMessage(playerid, GREEN, "You have finished your work.");
        format(string, sizeof(string), "%s puts the plastic bag inside the garbage bin.", GetICName(playerid));
        SendRPChatMessage(playerid, ACTION_COLOR, string, 5);
        PlayerStat[playerid][CollectingGarbage] = 0;
        PlayerStat[playerid][AbleToCollectGarbage] = 0;
        JobID1ReloadTimer = SetTimer("JobID1ReloadTime", 60000, false);
    }
    return 1;
}
Reply
#3

Thanks for the reply i will test this now.

EDIT: It works!! Thanks a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)