How to save random mission?
#1

Код:
enum MisLocationsEnum
{
    ID,
    LoadName[128],
    Float:LoadX,
    Float:LoadY,
    Float:LoadZ,
    Float:UnloadX,
    Float:UnloadY,
    Float:UnloadZ,
    Pay
}

new MisLocations[][MisLocationsEnum] =
{
	{10, "weapons from ammunition store to main army base", -307.1,836.4,12.2, 135.1,1946.2,19.0},
	{11, "beer from LV Brewery to LS McDonalds", 275.1,1355.2,10.3, 1194.7,-880.5,42.7},
	{12, "Samsung Galaxy S4 from LS Refinery to LV Market", 2202.2,-2253.4,14.55, 2823.0,2602.7,10.5},
	{13, "dildos from SF Refinery to LV Sexshop", -1704.6,13.8,4.5, 1988.1,2073.8,11.8},
	{13, "money from SF Bank to LS Casino", -2440.2,514.0,30.9, 1905.2,959.9,11.8},
	{14, "fresh steak from SF Farm to LS Cluckin bell", -1459.9,-1456.2,101.4, 2397.2,-1499.7,23.5},
	{15, "Medical Marihuana from SF Farm to LV Hospital", -1169.5,-1136.6,128.9, 1630.0,1800.1,10.5},
	{16, "rocks from LA Worksite to SF Biggest mountain", 586.4,854.0,-42.7, -2328.4,-1623.0,483.4},
	{17, "sport cars from LV Airport to LS Grotti Car Sale", 1633.5,1638.2,11.4, 544.3,-1280.0,16.9}
};
stock T_NewJob(playerid)
{
        new vID = GetPlayerVehicleID(playerid); //gets called on the next line
	if(T_OnMission[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"You are already working.");
    if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)//this checks wether the player is in a Roadtrain, Tanker or Linerunner
    {
        if(IsTrailerAttachedToVehicle(vID))// This checks wether the player has a trailer attached
        {
            new MisRand = random(sizeof(MisLocations));// this is the line that will call a random mission.
            new LoadText[128], Float:x, Float:y, Float:z;// these are where we will store each co-ord and the text for the mission
            x = MisLocations[MisRand][LoadX];//this sets one of the above
            y = MisLocations[MisRand][LoadY];//this sets one of the above
            z = MisLocations[MisRand][LoadZ];//this sets one of the above
            unx[playerid] = MisLocations[MisRand][UnloadX];//these set what we made in step 10.
            uny[playerid] = MisLocations[MisRand][UnloadY];//these set what we made in step 10.
            unz[playerid] = MisLocations[MisRand][UnloadZ];//these set what we made in step 10.
			iPay[playerid] = GetDistance(x,y,z,unx[playerid],uny[playerid],unz[playerid]);
			SetPlayerCheckpoint(playerid, x, y, z, 7);
            format(LoadText, 128, "Deliver %s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console
            SendClientMessage(playerid, 0xFFFFFF, "_____________________");//sends message in console
            SendClientMessage(playerid, 0xFFFFFF, "");//sends message in console
            SendClientMessage(playerid, 0x33CCFFAA, LoadText);//sends the text we formatted earlier in console
            SendClientMessage(playerid, 0xFFFFFF, "_____________________");//sends message in console
            T_OnMission[playerid] = 1;
        }
        else//if the player doesnt have a trailer attached
        {
            SendClientMessage(playerid, COLOR_WHITE, "You need a trailer!");//sends message in console
        }
    }
    else//if the player isnt in a truck
    {
        SendClientMessage(playerid, COLOR_WHITE, "You must be in a Truck in order to work!");//sends message in console
    }
    return 1;
}
//-------------------[Stop Work]---------------------------------------
stock StopWork(playerid)
{
	if(T_OnMission[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not on mission.");
    T_OnMission[playerid] = 0;
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid, COLOR_WHITE, "You chose to cancel the mission and got fined $1000");
    GivePlayerMoney(playerid, -1000);
    return 1;
}
stock CheckpointEntered(playerid)
{
	new string[300];
    new vID = GetPlayerVehicleID(playerid);//Explained earlier
    if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_WHITE, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
    if(T_OnMission[playerid] == 1)//checks the players mission status
    {
        DisablePlayerCheckpoint(playerid);//disables the checkpoint
        SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
        SendClientMessage(playerid, COLOR_WHITE, "Loaded. Please head to the second checkpoint!");//sends message
        T_OnMission[playerid] = 2;//sets the players mission status
    }
    else if(T_OnMission[playerid] == 2)//checks the mission status of the player
    {
        new LoadText[128];
		format(string,sizeof(string),"Well done. You have completed your mission and earned %d$",iPay[playerid]*5);
        GivePlayerMoney(playerid,iPay[playerid]*5);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        DisablePlayerCheckpoint(playerid);//disables the checkpoint
        T_OnMission[playerid] = 0;
        SetPlayerScore(playerid, GetPlayerScore(playerid)+2);//gives the player 2 score
		new INI:File = INI_Open(UserPath(playerid));
    	INI_SetTag(File,"data");
  	  	INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    	INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
    	INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    	INI_Close(File);
    }
    return 1;
}
What I would like to do is that it saves this
Код:
format(LoadText, 128, "Deliver %s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console
And once the mission is completed it would take that mission and send a player message to all that somebody has delivered that from there to there.. basical took the format and only modified it a little, but it would have to be the same mission and not MisRand

I hope it's understandable enough ^^
Reply
#2

So at the end of the mission It would say to the players that: Somebody has delivered ....
Reply
#3

Basically when you start a mission it tells you Deliver "missiontext(something from somewhere to somewhere". Once you would finish the minish I would like to use the mission text and just change it so all the server would see: Playername has delivered "missiontext(something from somewhere to somewhere".
Reply
#4

Bumpulos ^^
Reply
#5

So basically it's just like the code you gave us, but when the mission ends, you must do this:
pawn Код:
// This is where he ends the mission
new string[256];
format(string, sizeof(string), "%s has delivered %s!", GetPlayerName[playerid], MisLocations[MisRand][LoadName]);
SendClientMessageToAll(COLOR_WHITE, string);
I hope this is what you mean, else we need more explanation please
Reply
#6

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
So basically it's just like the code you gave us, but when the mission ends, you must do this:
pawn Код:
// This is where he ends the mission
new string[256];
format(string, sizeof(string), "%s has delivered %s!", GetPlayerName[playerid], MisLocations[MisRand][LoadName]);
SendClientMessageToAll(COLOR_WHITE, string);
I hope this is what you mean, else we need more explanation please
Код:
stock CheckpointEntered(playerid)
{
	new string[300];
    new vID = GetPlayerVehicleID(playerid);//Explained earlier
    if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_WHITE, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
    if(T_OnMission[playerid] == 1)//checks the players mission status
    {
        DisablePlayerCheckpoint(playerid);//disables the checkpoint
        SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
        SendClientMessage(playerid, COLOR_WHITE, "Loaded. Please head to the second checkpoint!");//sends message
        T_OnMission[playerid] = 2;//sets the players mission status
    }
    else if(T_OnMission[playerid] == 2)//checks the mission status of the player
    {
		if(iPay[playerid] < 10001){
		iScore[playerid] = 1;
		}
		else if(iPay[playerid] < 20001){
		iScore[playerid] = 2;
		}
		else if(iPay[playerid] > 20000){
		iScore[playerid] = 3;
		}
		format(string,sizeof(string),"Well done. You have completed your mission and earned %d$ and %d score.",iPay[playerid]*5,iScore[playerid]);
		TextDrawSetString(Textdraw0[playerid],"       You are currently not on mission. Use /work to start working.");
        GivePlayerMoney(playerid,iPay[playerid]*5);
        SendClientMessage(playerid, COLOR_YELLOW, string);
		new string2[256],name[30];
		GetPlayerName(playerid,name,sizeof(name));
		format(string2, sizeof(string2), "%s has delivered %s!", name, MisLocations[MisRand][LoadName]); //line 296
		SendClientMessageToAll(COLOR_YELLOW, string2);
        DisablePlayerCheckpoint(playerid);//disables the checkpoint
        T_OnMission[playerid] = 0;
        SetPlayerScore(playerid, GetPlayerScore(playerid)+iScore[playerid]);//gives the player 2 score
		new INI:File = INI_Open(UserPath(playerid));
    	INI_SetTag(File,"data");
  	  	INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    	INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
    	INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    	INI_Close(File);
    }
    return 1;
}
C:\Users\Dorian\Desktop\sa-mp\gamemodes\bhaulers.pwn(296) : error 017: undefined symbol "MisRand"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#7

Alright try this:
pawn Код:
new string[256];
format(string, sizeof(string), "%s has delivered %s!", GetPlayerName[playerid], MisLocations[][LoadName]);
SendClientMessageToAll(COLOR_WHITE, string);
Reply
#8

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
Alright try this:
pawn Код:
new string[256];
format(string, sizeof(string), "%s has delivered %s!", GetPlayerName[playerid], MisLocations[][LoadName]);
SendClientMessageToAll(COLOR_WHITE, string);
Код:
C:\Users\Dorian\Desktop\sa-mp\gamemodes\bhaulers.pwn(296) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#9

Which is line 296 ?
Reply
#10

Quote:
Originally Posted by kartik
Посмотреть сообщение
Which is line 296 ?
format(string, sizeof(string), "%s has delivered %s!", GetPlayerName[playerid], MisLocations[][LoadName]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)