[HELP]Robbery system : Commands and checkpoints
#1

hey guys.

Ok here is my problem. I have made a robbery system for which the player must stand in the dynamic checkpoint and then he must enter a command to start robbing. I want to change it that the player doesnt have to use a command and that he goes into the checkpoint and the robbery must then start automatically. I will post all the coding i have done with this system. I will only post the coding of one shop.

Right down here i forwarded.

Код:
forward robBarber(playerid);
Right down here i declared the timers and checkpoints and such more.

Код:
new
    robTimerB[ MAX_PLAYERS ],
    cp_Barber,
    bool: pRobbingB[ MAX_PLAYERS ],	//Los Santos, Idlewood, Barber Shop
    bool: BarberRobbed;
Then placed the coordinates of where the checkpoint must be with a 3D Text Label.

Код:
	Create3DTextLabel("/robbarber", COLOR_YELLOW, 413.265 , -17.957 , 1001.804, 40.0, 0, 0);   		
	cp_Barber = CreateDynamicCP(413.265 , -17.957 , 1001.804, 2.0, .interiorid = 2);
Right down i here i made my public which does few of the things.

Код:
public robBarber(playerid)			//Barber Shop LS
{
    new
        randMoney = random(8000) + 1000;
   
    new
        szStr[ 128],
        usrName[24],
		string[128];

    GetPlayerName( playerid, usrName, 24 );
    format( szStr, 128, "%s has robbed $%d from the Barber Shop", usrName, randMoney );
    SendClientMessageToAll( COLOR_ORANGERED, szStr );

    format( szStr, 128, "{CC6600}[ROBBERY INFO] {FFFFFF}Robbery successful! You have earned {CC6600}$%d {FFFFFF}, Score Earned : {CC6600}1 ", randMoney );
    SendClientMessage( playerid, COLOR_WHITE, szStr );

    pRobbingB[ playerid ] = false;
    SetTimer( "barberDelay", 90000, false );

	pInfo[playerid][Cash] += randMoney;

    pInfo[playerid][Score] += 1;
	pInfo[playerid][Robs] += 1;
	format(string, 128, "{CC6600}[ROBBERY INFO] {FFFFFF}Your robbing skill has increased to {CC6600}%d", pInfo[playerid][Robs]);
	SendClientMessage(playerid, COLOR_WHITE, string);
	
	new color = GetPlayerColor(playerid);
	if(color == COLOR_WHITE)
		return SetPlayerColor(playerid, COLOR_ORANGE);
	else if(color == COLOR_ORANGE)
		return SetPlayerColor(playerid, COLOR_RED);
	return 1;
}
And i made a few things under "OnPlayerEnterDynamicCP" with the checkpoint. Right down here

Код:
if (pRobbingB[playerid])
	{
			if (checkpointid == cp_Barber)
			{
				pRobbingB[playerid] = false;
				KillTimer(robTimerB[playerid]);
				BarberRobbed = false;
				GameTextForPlayer(playerid, "~r~You have failed the robbery!", 1000, 3);
			}
	}
Down here i made a delay public which works with the timer.

Код:
forward barberDelay( );
public barberDelay( )
{
    BarberRobbed = false;
    return true;
Now finally down here is the command the player must first type to rob the barber shop.

Код:
CMD:robbarber(playerid, params[])		//Barber Shop, Idlewood
{
    if (pRobbingB[ playerid ])
        return SendClientMessage( playerid, COLOR_RED, "ERROR:{FFFFFF} You are already robbing Idlewood Barber Shop" );

    if (!IsPlayerInRangeOfPoint( playerid, 3.0, 413.265 , -17.957 , 1001.804 ) )
		return SendClientMessage( playerid, COLOR_RED, "ERROR:{FFFFFF} You must be in the checkpoint at Idlewood Barber Shop to use this command!" );

    if (BarberRobbed )
        return SendClientMessage( playerid, COLOR_WHITE, "{CC6600}Idlewood Barber Shop {FFFFFF}has been {CC6600}robbed recently." );

    robTimerB[ playerid ] = SetTimerEx( "robBarber", 30000, false, "i", playerid );
    SendClientMessage( playerid, COLOR_YELLOW, "[ROBBERY INFO] You have started a robbery, it will last 30 seconds. Do not leave the checkpoint!" );

    pRobbingB[ playerid ] = true;
    BarberRobbed = true;

 //     format( szStr, 128, "[ROBBERY] %s has began a robbery at Idlewood Pizza!", GetName(playerid) );
 //     SendClientMessageToAll( COLOR_ORANGERED, szStr );

    GameTextForPlayer( playerid, "~g~Robbery in process~n~~r~Do not leave the checkpoint!", 32000, 3 );
    SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
    return 1;
}
Any help will be appreciated guys. Just show me how the command's code can go into the OnPlayerEnterDynamicCP. So that the player doesnt have to enter a command to rob the store.
Reply
#2

if(checkpointid == cp_Barber)
{
robTimerB[ playerid ] = SetTimerEx( "robBarber", 30000, false, "i", playerid );
SendClientMessage( playerid, COLOR_YELLOW, "[ROBBERY INFO] You have started a robbery, it will last 30 seconds. Do not leave the checkpoint!" );

pRobbingB[ playerid ] = true;
BarberRobbed = true;

// format( szStr, 128, "[ROBBERY] %s has began a robbery at Idlewood Pizza!", GetName(playerid) );
// SendClientMessageToAll( COLOR_ORANGERED, szStr );

GameTextForPlayer( playerid, "~g~Robbery in process~n~~r~Do not leave the checkpoint!", 32000, 3 );
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
return 1;
}

That's all you have to do. Then add the opposite to OnPlayerLeaveDynamicCP. Also it would be more efficient to create a custom function like RobBarber(playerid) and place the command code under there.
Reply
#3

Wait Wait, i dont understand. can i just drag the Commands data over to the OnPlayerEnterDynamicCP
Reply
#4

Quote:
Originally Posted by MrViolence101
Посмотреть сообщение
Wait Wait, i dont understand. can i just drag the Commands data over to the OnPlayerEnterDynamicCP
Yeah you can, it's the same code but just a different way of calling it.
Reply
#5

If i put that coding you gave me now into my OnPlayerEnterDynamicCP. will it work?
Reply
#6

Can you make a coding like
Код:
 Example
and show me precisely what i must insert into the OnPlayerEnterDynamicCP. I wil Rep++
Reply
#7

Yeah it should, if not post here again and I'll help you out.
Reply
#8

Quote:
Originally Posted by Divergent
Посмотреть сообщение
Yeah it should, if not post here again and I'll help you out.
Check above your reply, i replied
Reply
#9

Код:
	if(pRobbingB[playerid])
	{
		if(checkpointid == cp_Barber)
		{
			robTimerB[playerid] = SetTimerEx( "robBarber", 30000, false, "i", playerid);
			SendClientMessage(playerid, COLOR_YELLOW, "[ROBBERY INFO] You have started a robbery, it will last 30 seconds. Do not leave the checkpoint!");

			pRobbingB[playerid] = true;
			BarberRobbed = true;

			// format( szStr, 128, "[ROBBERY] %s has began a robbery at Idlewood Pizza!", GetName(playerid) );
			// SendClientMessageToAll( COLOR_ORANGERED, szStr );

			GameTextForPlayer(playerid, "~g~Robbery in process~n~~r~Do not leave the checkpoint!", 32000, 3);
			SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
			return 1;
		}
	}
Reply
#10

Quote:
Originally Posted by Divergent
Посмотреть сообщение
Код:
	if(pRobbingB[playerid])
	{
		if(checkpointid == cp_Barber)
		{
			robTimerB[playerid] = SetTimerEx( "robBarber", 30000, false, "i", playerid);
			SendClientMessage(playerid, COLOR_YELLOW, "[ROBBERY INFO] You have started a robbery, it will last 30 seconds. Do not leave the checkpoint!");

			pRobbingB[playerid] = true;
			BarberRobbed = true;

			// format( szStr, 128, "[ROBBERY] %s has began a robbery at Idlewood Pizza!", GetName(playerid) );
			// SendClientMessageToAll( COLOR_ORANGERED, szStr );

			GameTextForPlayer(playerid, "~g~Robbery in process~n~~r~Do not leave the checkpoint!", 32000, 3);
			SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
			return 1;
		}
	}
When i walk into the checkpoint nothing responds
Reply


Forum Jump:


Users browsing this thread: