SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/07/2016, 07:48 PM   #1
Skillzz
Little Clucker
 
Join Date: Feb 2013
Location: United Kingdom
Posts: 37
Reputation: 1
Default Checkpoint Problem

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:
Code:
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
Code:
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.ph...ght=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.
Skillzz is offline   Reply With Quote
Old 06/07/2016, 10:26 PM   #2
GangstaaSunny
Little Clucker
 
GangstaaSunny's Avatar
 
Join Date: Jun 2012
Location: Hamburg, Germany
Posts: 28
Reputation: 15
Default Re: Checkpoint Problem

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.
__________________


GangstaaSunny is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkpoint problem sscarface Scripting Help 1 27/01/2013 12:28 PM
checkpoint problem +REP peterory Scripting Help 2 09/06/2012 08:00 AM
checkpoint problem CrazyBlob Help Archive 28 20/05/2011 09:48 AM
problem with checkpoint Pawno_Master Help Archive 18 04/07/2009 12:05 PM


All times are GMT. The time now is 07:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.