PDA

View Full Version : Checkpoint Problem


Skillzz
06/07/2016, 07:48 PM
Hello again,

I've got a problem with my game mode, I type /robstore and everything works, but when I'm in the alternative checkpoints it shows as I'm in the first one being CP_Idlewood_Tattoo - This being the tattoo shop in Idlewood.

Command /robstore:
cmd(robstore, playerid, params[])
{
#pragma unused params
// Idlewood Tattoo Robbery
if(IsPlayerInDynamicCP(playerid, CP_Idlewood_Tattoo))
{
if(tattoorobbedrecently >=1)
{
SendClientMessage(playerid, COLOR_ERROR, "Error: The Tattoo Parlor has been robbed recently.");
return 1;
}
ROBBING_TATTOO[playerid] = 15;
tattoorobbedrecently = 180;
return 1;
}

if(IsPlayerInDynamicCP(playerid, CP_Idlewood_ReecesHair))
{
if(reeceshairrobbedrecently >=1)
{
SendClientMessage(playerid, COLOR_ERROR, "Error: Reece's Hair & Facial Studio has been robbed recently.");
return 1;
}
ROBBING_REECESHAIR[playerid] = 15;
reeceshairrobbedrecently = 180;
return 1;
}
return 1;
}




Then this is where the robbery actually happens

public ServerRobbery()
{
new pname[24]; new ID;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(ROBBING_TATTOO[i] > 1)
{
ROBBING_TATTOO[i] --;
new time[20];
format(time,sizeof(time),"Time Remaining: %d",ROBBING_TATTOO[i]);
GameTextForPlayer(i,time,125,3);
}
if(ROBBING_TATTOO[i] == 1)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(i,pName,MAX_PLAYER_NAME);
SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 4);
ROBBING_TATTOO[i] =0;
new mrand = random(27000);
IncreaseScore(i, 1);
format(string,sizeof(string),"%s(%d) has robbed a total of $%d from the Idlewood Tattoo Parlor!",pName,i,mrand);
SendClientMessageToAll(COLOR_RED,string);
GivePlayerMoney(i, mrand);

if(gTeam[ID] == Team_Cop || gTeam[ID] == Team_FBI || gTeam[ID] == Team_Army)
{
new playerid;
format(string, 120, "Police Dispatch: %s(%d) is currently robbing the Tattoo Parlor in Idlewood.", pname, playerid);
SendCopMessage(string);
format(string, 120, "Type /radoff to turn off the Police Radio.");
SendCopMessage(string);
SetPVarInt(playerid, "RobSkill", GetPVarInt(playerid, "RobSkill") +1);
format(string, 120, "Skill Upgrade: Your robbing skill has increased. Read /stats for more player statistics");
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
}// End of Idlewood Tattoo Robbery

// Start of Reece's Hair & Facial Robbery
if(ROBBING_REECESHAIR[i] > 1)
{
ROBBING_REECESHAIR[i] --;
new time[20];
format(time,sizeof(time),"Time Remaining: %d",ROBBING_REECESHAIR[i]);
GameTextForPlayer(i,time,125,3);
}
if(ROBBING_REECESHAIR[i] == 1)
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(i,pName,MAX_PLAYER_NAME);
SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 4);
ROBBING_REECESHAIR[i] =0;
new mrand = random(27000);
IncreaseScore(i, 1);
format(string,sizeof(string),"%s(%d) has robbed a total of $%d from the Reece's Hair & Facial Studio!",pName,i,mrand);
SendClientMessageToAll(COLOR_RED,string);
GivePlayerMoney(i, mrand);
if(gTeam[ID] == Team_Cop || gTeam[ID] == Team_FBI || gTeam[ID] == Team_Army)
{
new playerid;
format(string, 120, "Police Dispatch: %s(%d) is currently robbing Reece's Hair & Facial Studio in Idlewood.", pname, playerid);
SendCopMessage(string);
format(string, 120, "Type /radoff to turn off the Police Radio.");
SendCopMessage(string);
SetPVarInt(playerid, "RobSkill", GetPVarInt(playerid, "RobSkill") +1);
format(string, 120, "Skill Upgrade: Your robbing skill has increased. Read /stats for more player statistics");
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
}// End of Reece's Hair & Facial Robbery
}
}
return 1;
}

I'm still quite new to scripting and have referred to this tutorial here: http://forum.sa-mp.com/showthread.php?t=505857&highlight=checkpoint

Hopefully this is how it works and I've done it correctly, if not I'd appreciate if someone could show me where I've gone wrong in my script.

Also: When I've robbed the tattoo shop and go into the hair studio, it will not let me rob it as I've just robbed the tattoo shop. I want to be able to rob a store right after I rob the other one if that makes sense.

Thanks in advance.

GangstaaSunny
06/07/2016, 10:26 PM
Hello Skillzz,
recheck the coordinates of both checkpoints and also the distance for them.

Also use an "else if" inside your /robstore command to prevent calling the code inside the braces.