How to add Chance ?
#1

Hello, How to i can add Chance for Robbery 1/2 Chance? Please help me... im creating the command but i want to know how to create a change of rob

Код:
CMD:robbery(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_Warehouse)) return SendClientMessage(playerid, COLOR_RED,"You are not in a Warehouse Checkpoint!!");
    {
        if(Warehouserobbedrecently >=1) //checking if WArehouse has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "[ROBBERY]: Warehouse has been robbed recently"); // sending error message
        }
        ROBBING_Warehouse[playerid] = 60; // setting the robbery timer
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +5);
        Warehouserobbedrecently =200; // Time the players needs to wait for starting an another robbery in the same place
    }
    return 1;
}

forward ServerRobbery();
public ServerRobbery()
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i)) // checking if player connected
            {
                //ROBBERIES
                if(ROBBING_Warehouse[i] > 1) // Checking if robbery time is above 1
                {
                    ROBBING_Warehouse[i] --; // Decreasing time
                    new time[20]; //adding time variable
                    format(time,sizeof(time),"~b~Robbery Time:%d",ROBBING_Warehouse[i]);
                    SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 4); //giving player 4 wanted level
                    GameTextForPlayer(i,time,500,3); //shows gametext showing the time remaining for the robbery
				}
                if(ROBBING_Warehouse[i] == 1) // IF the timer reached 1
                {

                	new string[64], pName[MAX_PLAYER_NAME];// getting player name
                	GetPlayerName(i,pName,MAX_PLAYER_NAME);
                    SendClientMessage(i, COLOR_GREEN, "Robbery Complete"); //sending message to the player that robbery was complete
                    ROBBING_Warehouse[i] =0; // RESET timer
                    new mrand =random(200000);
                    format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed a total of $%d from Warehouse!",pName,i,mrand);
                    SendClientMessageToAll(COLOR_RED,string);

                    GivePlayerMoney(i, mrand);
                }
		   }
        }
        return 1;
}
help or give me a tutoiral of how to make change of robbing
Reply
#2

Info:

You can use random, its part of the sa-mp library and can be used to create a random number via a max amount passed in as a parameter.

Example:
Код:
new 
	value
;

value = random( 100 ); // will random create a number between 0 - 99

switch( value )
{
	case 0 .. 49: // Rob Successful
	{}

	case 50 .. 99: // Rob Failed
	{}
}
I hope you managed to understand this?

Wiki - Link
Reply
#3

That's is to hard to make to another's stores ... so do you have easy ways?
Reply
#4

I'm sorry you lost me?

This is the easiest way to do it?

You can modify the 'random' parameter to be less, and also edit the switch cases, to match the min and max of the value of 'value'.

There really isn't an 'easier' way to do it.
Reply
#5

Quote:
Originally Posted by azzerking
Посмотреть сообщение
I'm sorry you lost me?

This is the easiest way to do it?

You can modify the 'random' parameter to be less, and also edit the switch cases, to match the min and max of the value of 'value'.

There really isn't an 'easier' way to do it.
no man, but if you can edited my codes i put To i can undersetand it.... if u can
Reply
#6

Here is your code finished, though in future most people won't be as nice to do it for you. I hope you learn from what I have done, and actually apply it in the future.

Код:
CMD:robbery(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_Warehouse)) return SendClientMessage(playerid, COLOR_RED,"You are not in a Warehouse Checkpoint!!");
    {
        if(Warehouserobbedrecently >=1) //checking if WArehouse has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "[ROBBERY]: Warehouse has been robbed recently"); // sending error message
        }

        new
            can_rob
        ;

        can_rob = random( 100 );

        switch( can_rob )
        {
            case 0 .. 49: // successful robbery
            {
                ROBBING_Warehouse[playerid] = 60; // setting the robbery timer
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +5);
                Warehouserobbedrecently = 200; // Time the players needs to wait for starting an another robbery in the same place

                return 1;
            }
            
            default:
            {
                // send error message
            }
        }
    }

    return 1;
}
Reply
#7

Quote:
Originally Posted by azzerking
Посмотреть сообщение
Here is your code finished, though in future most people won't be as nice to do it for you. I hope you learn from what I have done, and actually apply it in the future.

Код:
CMD:robbery(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_Warehouse)) return SendClientMessage(playerid, COLOR_RED,"You are not in a Warehouse Checkpoint!!");
    {
        if(Warehouserobbedrecently >=1) //checking if WArehouse has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "[ROBBERY]: Warehouse has been robbed recently"); // sending error message
        }

        new
            can_rob
        ;

        can_rob = random( 100 );

        switch( can_rob )
        {
            case 0 .. 49: // successful robbery
            {
                ROBBING_Warehouse[playerid] = 60; // setting the robbery timer
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +5);
                Warehouserobbedrecently = 200; // Time the players needs to wait for starting an another robbery in the same place

                return 1;
            }
            
            default:
            {
                // send error message
            }
        }
    }

    return 1;
}
Hello, its really hard man, There is a easy ways? Look im looking for a tutoiral how it im not find can some one give me a Chance Rob? [Failed , Succesfully ]
Reply
#8

This is all I can find in a quick search.


Link #1
Link #2


Other then that your out of look for tutorial on a robbery system. I'm sorry but if your not willing to listen to what we have put, since we have written the code for you, then there nothing we can do to help you. Your clearly not willing to help yourself, and instead are wanting us to do it for you.

I suggest you actually think about it, and start trying to fix it yourself.
Reply
#9

Hi, i found a NVCNR and i searching for a command and i got Like that

Код:
CMD:robnvpd(playerid, params[])
{
	if(GetTeam{playerid} != CLASS_CIV) return SendClientMessage(playerid, RED, "Only civilians can rob places.");
	if(IsRobbingNVPD{playerid} == true) return SendClientMessage(playerid, RED, "Your already robbing the joint.");
	if(IsPlayerHoldingAGun(playerid) == 0 || HasBeenCuffed{playerid} == true) return SendClientMessage(playerid, RED, "You must be holding a gun to rob places.");
    if((gettime() - 120) < TimerInfo[playerid][CMD_timer21]) return SendClientMessage(playerid, RED, "Please wait before using this command again.");
    TimerInfo[playerid][CMD_timer21] = gettime();
	new chance = random(3);
	if(chance == 0)
	{
	    format(fstr, sizeof(fstr),  "[DISPATCH]: Suspect %s [%d] has attempted to rob the NVPD at New Vegas Square.", GetName(playerid), playerid);
        CopRadio(BLUE, fstr);
        SendClientMessage(playerid, RED, "You have failed to rob the NVPD.");
	    GameTextForPlayer(playerid, "~w~Robbery ~r~Failed", 5000, 5);
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
	}
	else if(IsPlayerInRangeOfPoint(playerid,1.0,230.0261,165.0891,1003.0234))
    {
	    if((gettime() - 120) < nvpdrobbed) return SendClientMessage(playerid, RED, "This place has been robbed recently, try again later.");
        format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s [%d] is now robbing the NVPD at New Vegas Square.", GetName(playerid), playerid);
        CopRadio(BLUE, fstr);
        SendClientMessage(playerid, LIGHTGREEN, "Your robbing the NVPD, DON'T LEAVE THE CHECKPOINT!");
	    GameTextForPlayer(playerid, "~r~Holdup ~w~In ~g~Progress...~n~~r~Dont Leave ~w~The ~r~Checkpoint.", 25000, 5);
        SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+6);
	    IsRobbingNVPD{playerid} = true;
        nvpdtimer{playerid} = SetTimerEx("NVPDRob", 25000, false, "d", playerid);
        ApplyAnimation(playerid,"ped","ARRESTgun",4.1,0,1,1,1,1);
        nvpdrobbed = gettime();
	}
	else
	{
        SendClientMessage(playerid, RED, "Your not at the robbery checkpoint.");
	}
	new astring[100],pName[24];
	GetPlayerName(playerid,(pName),sizeof(pName));
    format(astring,sizeof(astring),"%s [%d] typed: /robnvpd",pName,playerid);
    SendAdminMessage(GREY,astring);
	return true;
}
So now, Here having a Chance for robbing, Example: Robbery Failed Like that how to i can do it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)