Random command help ! pls.
#1

Hi. I want to make several missions


/mission 1

/mission 2

but i want to make a single command /mission and randomly to give those missions [1,2,3] and 1 mission per hour, even if the same mission gets repeated.


ex.

Player on East LS. Types /mission

Error mesage: Go to Army Stadion . (Places checkpoint on Army Stadion)
He goes into checkpoint, types /mission.
He gets random mission.

How can i start?

PHP код:
CMD:mission(playerid)

if (
IsPlayerInCheckpoint(playerid))
{
DisablePlayerCheckpoint(playerid)
 
GiveMission(playeridrandom);
}
else  return  
SendClientMessage(playerid, -1""chat" Go to Military Base to get a mission");

is this good?
Reply
#2

You could give each mission an ID. And then use a random number to select the id.

PHP код:
GiveMission(playerid); 
I have something similar to select random fire scenes.

You could do something like this:

PHP код:
GiveMission(playerid)
{
    new 
MissionID randomEx(1,3); Will output random number 1-3
    
if(MissionID == 1)
    {
        
//start first mission
       
StartMission(playerid1); 
    }
    else if(
MissionID == 2)
    {
        
// start second mission
       
StartMission(playerid2); 
    }
    else if(
MissionID == 3)
    {
        
//start third mission
       
StartMission(playerid3); 
    }
    else{ 
printf("ERROR: INVALID MISSION ID"); }

Reply
#3

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
You could give each mission an ID. And then use a random number to select the id.

PHP код:
CMD:mission(playerid)
{
    if(
IsPlayerInRangeOfPoint(playerid,1.1,-216.8123,984.9861,19.3925,94.2272))
               {
        
SendClientMessage(playerid,COLOR_WHITE,"Let's see what mission you will get !");
        }
        else return 
SendClientMessage(playerid, -1""chat" You need to be on the right place !");
        
SetPlayerCheckpoint(playerid, -216.8123,984.9861,19.3925,94.2272);

what is wrong with this cmd?

PHP код:
(20398) : warning 202number of arguments does not match definition
(20401) : error 010invalid function or declaration 
Reply
#4

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
what is wrong with this cmd?
Nothing at all, i didnt give you a solution but a suggestion.
You could use it in your command like this:

PHP код:
CMD:mission(playerid
{  
if (
IsPlayerInCheckpoint(playerid)) 

DisablePlayerCheckpoint(playerid
 if(
MissionID == 1)
    {
        
//start first mission
       
StartMission(playerid1); 
    }
    else if(
MissionID == 2)
    {
        
// start second mission
       
StartMission(playerid2); 
    }
    else if(
MissionID == 3)
    {
        
//start third mission
       
StartMission(playerid3); 
    }

else  return  
SendClientMessage(playerid, -1""chat" Go to Military Base to get a mission"); 

and for the errors.
PHP код:
        else return SendClientMessage(playerid, -1""chat" You need to be on the right place !"); 
        
SetPlayerCheckpoint(playerid, -216.8123,984.9861,19.3925,94.2272); 
SetplayerCheckPoint only required 3 parameters i guess.

PHP код:
        else 
{
SendClientMessage(playerid, -1""chat" You need to be on the right place !"); 
        
SetPlayerCheckpoint(playerid, -216.8123,984.9861,19.3925); 

Also, dafuq is "chat"?
Reply
#5

I want to save my missions

Chat is the color, i defined it that way.

like

PHP код:
mission 1 =  
sendclientplayer Go kill 4 bandits.
if 
pInfo[i][BanditsKilled] = 4
AddSlotToInventoryWorld
(playe);rid,"Bandaj",1
mission 2 
=  
sendclientplayer Go kill 4 players.
if 
pInfo[i][Userskilled] = 4
AddSlotToInventoryWorld
(playe);rid,"Bandaj",
Reply
#6

You use SQL right? Create a table with missions.
Reply
#7

StartMission(playerid, 2);


How shall I define StartMission?
Reply
#8

As a function.
PHP код:
StartMission(playeridMissionID)
{
       
// the id is saved in MissionID

And StartMission(playerid, 2); should actually be:
PHP код:
StartMission(playeridMissionID); 
PHP код:
CMD:mission(playerid)  
{   
if (
IsPlayerInCheckpoint(playerid))  
{  
DisablePlayerCheckpoint(playerid)  
new 
MissionID randomEx(1,3);
StartMission(playeridMissionID);  
}  
else  return  
SendClientMessage(playerid, -1""chat" Go to Military Base to get a mission");  

Reply
#9

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
As a function.
.
PHP код:
stock StartMission(playerid1)
{
if 
pInfo[playerid][BanditsKilled] == 1
    
{
AddSlotToInventoryWorld(playerid,"Item",1);
SendClientMessage(playerid,-1,"*"COL_RED" You finished your mission. You received your prize!");
    }

PHP код:
CMD:mission(playerid)
{
if(
IsPlayerInRangeOfPoint(playerid,1.1,-216.8123,984.9861,19.3925))
{
new 
MissionID randomEx(1,3);
StartMission(playeridMissionID);
}
else  return  
SendClientMessage(playerid, -1""chat" Go to Military Base to get a mission");
}
return 
1;

Reply
#10

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
PHP код:
stock StartMission(playerid1)
{
if 
pInfo[i][BanditsKilled] == 1
    
{
AddSlotToInventoryWorld(playerid,"Bidon de Benzina Plina",1);
SendClientMessage(i,-1,"*"COL_RED" You finished your mission. You received your prize!");
    }

PHP код:
CMD:mission(playerid)
{
if(
IsPlayerInRangeOfPoint(playerid,1.1,-216.8123,984.9861,19.3925))
{
new 
MissionID randomEx(1,3);
StartMission(playeridMissionID);
}
else  return  
SendClientMessage(playerid, -1""chat" Go to Military Base to get a mission");
return 
1

Are you for real? this is where it goes wrong. You assume i am giving you a fully working code. but thats not the case.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)