SA-MP Forums Archive
Little help with OnPlayerEnterDynamicCP - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little help with OnPlayerEnterDynamicCP (/showthread.php?tid=274035)



Little help with OnPlayerEnterDynamicCP - Soumi - 04.08.2011

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.


Re: Little help with OnPlayerEnterDynamicCP - MadeMan - 04.08.2011

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;
}



Re : Little help with OnPlayerEnterDynamicCP - Soumi - 04.08.2011

Thanks for the reply i will test this now.

EDIT: It works!! Thanks a lot.