When i created many CP'S
#1

Hi, when i created many Checkpoints When i enter a cp i teleport to another CP ... Help pls

No ERRORS/Warrings but i want to when player enter a cp Teleport to placing i put it

[EDIT]: I need to make Multi cp's without wrong :/

Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid) //Add this anywhere
{
   if(checkpointid == CP_Warehouse) //Checking if player is in the checkpoint "Tatoo"
   {
    SendClientMessage(playerid, COLOR_RED, "Start robbery by typing /robbery"); //Sending message so that player knows that to rob. he must type this comman
   }
   if(checkpointid == CP_BankRobbing)
   {
	SendClientMessage(playerid, COLOR_YELLOW, "Type /robbank To start robbing");
	GameTextForPlayer(playerid, "/robbank", 5000,4);
   }
   if(checkpointid == CP_Bank)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Type /bank To open the Bank account {FC0101}[NOTE]{3CFC01}: You must create an account to safe your money");
   }
   if(checkpointid == CP_AmmuEnter)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Welcome to ammuation, You can Rob It Typing /robammu");
	 SetPlayerPos(playerid, 285.8931,-82.9310,1001.5156);
	 SetPlayerInterior(playerid, 4);
   }
   if(checkpointid == CP_AmmuExit)
   {
	 SetPlayerPos(playerid, 2535.9399,2083.5601,10.8203);
   }
   if(checkpointid == CP_AmmuMenu)
   {
	 SendClientMessage(playerid, -1, "Weapons Menu");
	 ShowPlayerDialog(playerid,AMMO_MENU,DIALOG_STYLE_LIST,"Weapons Menu","Armour\nSawn-off\nDesert Deagle\nSniper","Close","");
   }
   if(checkpointid == CP_BankVaultExit)
   {
	 SetPlayerPos(playerid, 2315.0574,-5.0479,26.7422);
	 GameTextForPlayer(playerid, "Exited", 5000, 1);
	 SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_autobahn)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Welcome to autobahn\nBuy Vehicles From Here");
   }
   if(checkpointid == CP_RefilFire)
   {
     if(GetPlayerSkin(playerid) != 279) return SendClientMessage(playerid, -1, "{FF0000}You Cant Refiled!! This only for a Fireman");
     {
	   GivePlayerWeapon(playerid, 42, 10000);
     }
   }
   if(checkpointid == CP_RefilMedic)
   {
	 if(GetPlayerSkin(playerid) != 276) return SendClientMessage(playerid, -1, "{FF0000}You cannot Refiled From HERE!!! This only for a Medic");
	 {
	   SetPlayerHealth(playerid, 100);
	   SetPlayerArmour(playerid, 30);
	   GivePlayerWeapon(playerid, 41, 1000);
	   SendClientMessage(playerid, COLOR_YELLOW, "You have been Refiled, Go Heal,Cure Players");
     }
   }
   if(checkpointid == CP_4DEnter)
   {
	   SetPlayerPos(playerid, 2010.9968,1017.8394,994.4688);
	   SetPlayerInterior(playerid, 10);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Four Dragons Casino.");
   }
   if(checkpointid == CP_4DExit)
   {
	   SetPlayerPos(playerid, 2025.5282,1008.5174,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_AmmuEnter)
   {
	   SetPlayerPos(playerid, 314.820983,-141.431991,999.601562);
	   SetPlayerInterior(playerid, 7);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Ammutuion.");
   }
   if(checkpointid == CP_AmmuExit)
   {
	   SetPlayerPos(playerid, 2155.8867,943.6033,10.8203);
   }
   if(checkpointid == CP_RoyalEnter)
   {
	   SetPlayerPos(playerid, 1133.3475,-8.0336,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Royal Casino.");
   }
   if(checkpointid == CP_RoyalExit)
   {
	   SetPlayerPos(playerid, 2086.9509,1517.2908,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_ClownEnter)
   {
	   SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Clown's Pocket Casino.");
   }
   if(checkpointid == CP_ClownExit)
   {
	   SetPlayerPos(playerid, 2221.4114,1838.6093,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_RouletteEnter)
   {
	   SetPlayerPos(playerid, 1133.1409,-9.8420,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Roulette's Casino.");
   }
   if(checkpointid == CP_RouletteExit)
   {
	   SetPlayerPos(playerid, 2163.3359,2159.9373,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_ZIPEnter)
   {
	   SetPlayerPos(playerid, 160.8152,-91.1831,1001.8047);
	   SetPlayerInterior(playerid, 15);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the ZIP.");
   }
   if(checkpointid == CP_ZIPExit)
   {
	   SetPlayerPos(playerid, 2177.8569,2292.7600,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_CluckinEnter)
   {
	   SetPlayerPos(playerid, 365.3872,-7.5130,1001.8516);
	   SetPlayerInterior(playerid, 9);
   }
   if(checkpointid == CP_CluckinExit)
   {
	   SetPlayerPos(playerid, 2107.2139,2228.7803,11.0234);
	   SetPlayerInterior(playerid, 0);
   }
  return 1;
}
Reply
#2

help
Reply
#3

Keep if in the first place, and set else if for another
Reply
#4

If your SetPlayerPos lines put the player right smack in the middle of another checkpoint then obviously you will create a loop. Doesn't take a genius to figure that out.
Reply
#5

Yes vince is right

for example

PHP код:
 if(checkpointid == CP_AmmuEnter)
   {
     
SendClientMessage(playeridCOLOR_YELLOW"Welcome to ammuation, You can Rob It Typing /robammu");
     
SetPlayerPos(playerid285.8931,-82.9310,1001.5156);
     
SetPlayerInterior(playerid4);
   }
   if(
checkpointid == CP_AmmuExit)
   {
     
SetPlayerPos(playerid2535.9399,2083.5601,10.8203);
   } 
When player enter Checkpontid CP_AmmuEnter maybe you teleport him in the middle of checkpointid CP_AmmuExit and then is logical that the player will be teleported out! You need to SetPlayerPos elsewhere !
Reply
#6

Hi again,
Код:
else if(checkpointid == CP_4DEnter)
   {
	   SetPlayerPos(playerid, 2010.9968,1017.8394,994.4688);
	   SetPlayerInterior(playerid, 10);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Four Dragons Casino.");
   }
   else if(checkpointid == CP_4DExit)
   {
	   SetPlayerPos(playerid, 2025.5282,1008.5174,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_AmmuEnter)
   {
	   SetPlayerPos(playerid, 314.820983,-141.431991,999.601562);
	   SetPlayerInterior(playerid, 7);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Ammutuion.");
   }
   else if(checkpointid == CP_AmmuExit)
   {
	   SetPlayerPos(playerid, 2155.8867,943.6033,10.8203);
   }
   else if(checkpointid == CP_RoyalEnter)
   {
	   SetPlayerPos(playerid, 1133.3475,-8.0336,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Royal Casino.");
   }
   else if(checkpointid == CP_RoyalExit)
   {
	   SetPlayerPos(playerid, 2086.9509,1517.2908,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_ClownEnter)
   {
	   SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Clown's Pocket Casino.");
   }
   else if(checkpointid == CP_ClownExit)
   {
	   SetPlayerPos(playerid, 2221.4114,1838.6093,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_RouletteEnter)
   {
	   SetPlayerPos(playerid, 1133.1409,-9.8420,1000.6797);
	   SetPlayerInterior(playerid, 12);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Roulette's Casino.");
   }
   else if(checkpointid == CP_RouletteExit)
   {
	   SetPlayerPos(playerid, 2163.3359,2159.9373,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_ZIPEnter)
   {
	   SetPlayerPos(playerid, 160.8152,-91.1831,1001.8047);
	   SetPlayerInterior(playerid, 15);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the ZIP.");
   }
   else if(checkpointid == CP_ZIPExit)
   {
	   SetPlayerPos(playerid, 2177.8569,2292.7600,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_CluckinEnter)
   {
	   SetPlayerPos(playerid, 365.3872,-7.5130,1001.8516);
	   SetPlayerInterior(playerid, 9);
   }
   else if(checkpointid == CP_CluckinExit)
   {
	   SetPlayerPos(playerid, 2107.2139,2228.7803,11.0234);
	   SetPlayerInterior(playerid, 0);
   }
But problem still there... I Did the else if but still

Quote:

if(checkpointid == CP_AmmuEnter)
{
SendClientMessage(playerid, COLOR_YELLOW, "Welcome to ammuation, You can Rob It Typing /robammu");
SetPlayerPos(playerid, 285.8931,-82.9310,1001.5156);
SetPlayerInterior(playerid, 4);
}
if(checkpointid == CP_AmmuExit)
{
SetPlayerPos(playerid, 2535.9399,2083.5601,10.8203);

Can u give me more info?
Reply
#7

Have you considered Vince's post? This can also happen if any of your constants that you check your checkpoint id with holds the same value. Return your call back once a checkpoint is found. There's too many if statements, I suggest you to use switch.
Reply
#8

Hi, Sorry but im Not good with English so can you give me Example? Vince, guys? Please Exmaple for i understand
Reply
#9

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
Have you considered Vince's post? This can also happen if any of your constants that you check your checkpoint id with holds the same value. Return your call back once a checkpoint is found. There's too many if statements, I suggest you to use switch.
Switch only works for constant values (neither checkpointid nor the other Variables are constant). And too many if-statements is not an issue, just a thing you can optimize (OP tried else if, which didn't work as well).


Quote:
Originally Posted by Thanks
Посмотреть сообщение
Hi, Sorry but im Not good with English so can you give me Example? Vince, guys? Please Exmaple for i understand
He said, that if you teleport a player from CP 1 directly into CP 2, the player will be teleported again. Is that what happens?

If yes, teleport the players outside of the other CPs.

If that is not the case, make sure the variables CP_4DEnter, CP_4DExit, etc are holding the correct IDs.
If you are unsure, show us your CreateDynamicCP code!
Reply
#10

Here you go:

Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid) //Add this anywhere
{
   if(checkpointid == CP_Warehouse) //Checking if player is in the checkpoint "Tatoo"
   {
    SendClientMessage(playerid, COLOR_RED, "Start robbery by typing /robbery"); //Sending message so that player knows that to rob. he must type this comman
   }
   if(checkpointid == CP_BankRobbing)
   {
	SendClientMessage(playerid, COLOR_YELLOW, "Type /robbank To start robbing");
	GameTextForPlayer(playerid, "/robbank", 5000,4);
   }
   if(checkpointid == CP_Bank)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Type /bank To open the Bank account {FC0101}[NOTE]{3CFC01}: You must create an account to safe your money");
   }
   if(checkpointid == CP_AmmuEnter)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Welcome to ammuation, You can Rob It Typing /robammu");
	 SetPlayerPos(playerid, 285.8931,-82.9310,1001.5156);
	 SetPlayerInterior(playerid, 4);
   }
   if(checkpointid == CP_AmmuExit)
   {
	 SetPlayerPos(playerid, 2535.9399,2083.5601,10.8203);
   }
   if(checkpointid == CP_AmmuMenu)
   {
	 SendClientMessage(playerid, -1, "Weapons Menu");
	 ShowPlayerDialog(playerid,AMMO_MENU,DIALOG_STYLE_LIST,"Weapons Menu","Armour\nSawn-off\nDesert Deagle\nSniper","Close","");
   }
   if(checkpointid == CP_BankVaultExit)
   {
	 SetPlayerPos(playerid, 2315.0574,-5.0479,26.7422);
	 GameTextForPlayer(playerid, "Exited", 5000, 1);
	 SetPlayerInterior(playerid, 0);
   }
   if(checkpointid == CP_autobahn)
   {
	 SendClientMessage(playerid, COLOR_YELLOW, "Welcome to autobahn\nBuy Vehicles From Here");
   }
   if(checkpointid == CP_RefilFire)
   {
     if(GetPlayerSkin(playerid) != 279) return SendClientMessage(playerid, -1, "{FF0000}You Cant Refiled!! This only for a Fireman");
     {
	   GivePlayerWeapon(playerid, 42, 10000);
     }
   }
   if(checkpointid == CP_RefilMedic)
   {
	 if(GetPlayerSkin(playerid) != 276) return SendClientMessage(playerid, -1, "{FF0000}You cannot Refiled From HERE!!! This only for a Medic");
	 {
	   SetPlayerHealth(playerid, 100);
	   SetPlayerArmour(playerid, 30);
	   GivePlayerWeapon(playerid, 41, 1000);
	   SendClientMessage(playerid, COLOR_YELLOW, "You have been Refiled, Go Heal,Cure Players");
     }
   }
   else if(checkpointid == CP_4DEnter)
   {
	   SetPlayerPos(playerid, 2010.9968,1017.8394,994.4688);
	   SetPlayerInterior(playerid, 10);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the Four Dragons Casino.");
   }
   else if(checkpointid == CP_4DExit)
   {
	   SetPlayerPos(playerid, 2025.5282,1008.5174,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_AmmuEnter)
   {
     SendClientMessage(playerid, COLOR_YELLOW, "Welcome to ammuation, You can Rob It Typing /robammu");
     SetPlayerPos(playerid, 285.8931,-82.9310,1001.5156);
     SetPlayerInterior(playerid, 4);
   }
   else if(checkpointid == CP_AmmuExit)
   {
	   SetPlayerPos(playerid, 2535.9399,2083.5601,10.8203);
   }
   else if(checkpointid == CP_ZIPEnter)
   {
	   SetPlayerPos(playerid, 160.8152,-91.1831,1001.8047);
	   SetPlayerInterior(playerid, 15);
	   SendClientMessage(playerid, -1, "{FFFFFF}Type {0070FF}/robbery {FFFFFF}to start {FC991A}robbing {FC991A}the ZIP.");
   }
   else if(checkpointid == CP_ZIPExit)
   {
	   SetPlayerPos(playerid, 2177.8569,2292.7600,10.8203);
	   SetPlayerInterior(playerid, 0);
   }
   else if(checkpointid == CP_CluckinEnter)
   {
	   SetPlayerPos(playerid, 365.3872,-7.5130,1001.8516);
	   SetPlayerInterior(playerid, 9);
   }
   else if(checkpointid == CP_CluckinExit)
   {
	   SetPlayerPos(playerid, 2107.2139,2228.7803,11.0234);
	   SetPlayerInterior(playerid, 0);
   }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)