Random Point to Point Missions?
#1

I know in order to do this i need to use checkpoints, and a enum to house all the locations, but im not sure exactly how to go about doing this.
Basicly i want you to type a command, and have it select a random mission that goes from point a to b can someone maybe point me in the right direction i'm not asking for you to script it for me just some help if you can.
Reply
#2

this might put u on the right track although it uses zcmd (not tested)
At top with other declarations
pawn Code:
new Rmission[][] =
{
    xcoord,ycoord,zcoord//swap for some random co-ords
    xcoord,ycoord,zcoord
};
Your command
pawn Code:
COMMAND:mission(playerid,params[])
{
    new random = random(sizeof(Rmission));
    SetPlayerCheckpoint(playerid,Rmission[random][0],Rmission[random][1],Rmission[random][2],5.0);
    return 1;
}
Not sure if this will work but it should do as far as i can tell.
Reply
#3

This did not seem to work at all i just got serveral errors, i saw a script one time that had this, and all the missions were in a enum... thats all i can really remember about it though...
Reply
#4

Sorry i left out a ';' (semi colon) that might be errors sorry cant help u further.
Reply
#5

1) get the streamer plugin, if not already done:
http://forum.sa-mp.com/showthread.ph...ugin+incognito
2) i suggest ZCMD:
http://forum.sa-mp.com/showthread.ph...highlight=ZCMD
use the solidfiles link, i checked it, it works.
3) and indeed sscanf (i prefer the "old" version, coz its a readable script):
https://sampwiki.blast.hk/wiki/Sscanf_code
you either can
- simply copy and paste the code (stock) into your script.
or
- #include it by creating a new textdocument in the pawno/include directory and create the "sscanf.inc" textfile with notepad, then paste the code into it. you wont need to modify it anyways.

once you unpacked the includes (maybe created the sscanf.inc aswell) and put them in the "GTA Server/pawno/include/" directory, open your gamemode script and start pasting those few lines at the top of the script (not in any callback/function):
btw: dont forget to create a backup of your actual gamemode ^^
Code:
#include <streamer>
#include <zcmd>

//uncomment that if you did NOT paste the stock() into the script, but created the sscanf.inc file:
//#include <sscanf>

//some variables and arrays for holding the Locations count, Name of the Delivery Point etc.
const DeliveryMissionLocationsMAX=100;
new DeliveryMissionLocations;
new DeliveryMissionPickupOwner[DeliveryMissionLocationsMAX][64];
new Float:DeliveryMissionPosition[DeliveryMissionLocationsMAX][3];
new DeliveryMissionPickup[DeliveryMissionLocationsMAX];

//some colors...
#define MSGFAIL_COLOR 0xff55aaff
#define MSGINFO_COLOR 0x55ffaaff
#define MSGDBUG_COLOR 0xaa5555ff
insert the call for the DeliveryMissionLoad(); in your OnGameModeInit()
Code:
public OnGameModeInit()
{
	//blablabla
	DeliveryMissionLoad(); // here
	//blablabla
	return 1;
}
now its time to get the streamer working, this callback will trigger when you touch a pickup
Code:
public OnPlayerPickUpDynamicPickup(playerid,pickupid)
{
	new string[128];
	if(GetPVarInt(playerid,"DeliveriesRunning")>0)
	{
		if(pickupid==DeliveryMissionPickup[DeliveryStart[0]])
		{
			format(string,sizeof(string),"Warez recieved from %s, now get to %s",DeliveryMissionPickupOwner[DeliveryStart[0]],DeliveryMissionPickupOwner[DeliveryEnd[0]]);
			SendClientMessage(playerid,MSGINFO_COLOR,string);
			return 1;
		}
		if(pickupid==DeliveryMissionPickup[DeliveryEnd[0]])
		{
			format(string,sizeof(string),"Delivery successful. You recieve $%d as reward.",DeliveryBounty[0]);
			SendClientMessage(playerid,MSGSUCC_COLOR,string);
			SetPVarInt(playerid,"DeliveriesRunning",0);
			GivePlayerMoney(playerid,DeliveryBounty[0]);
			return 1;
		}
	}
	// no delivery running, no response at all. maybe this will help @ testing the command: (uncomment it)
//	SendClientMessage(playerid,MSGFAIL_COLOR,"No /delivery running");
	return 1;
}
these 2 commands will be useful for in-game loading newly created/edited positions and indeed for testing
Code:
CMD:delivery(playerid,params[])
{
	DeliveryMissionStart(playerid);
	return 1;
}

//feel free to change the command name
CMD:loaddeliverypositions(playerid,params[])
{
	if(!IsPlayerAdmin(playerid))
	{
	    SendClientMessage(playerid,MSGFAIL_COLOR,"Command not available.");
	    return 1;
	}
	DeliveryMissionLoad();
	return 1;
}
the loading part that gets called in OnGameModeInit, and on command /loaddeliverypositions
Code:
forward DeliveryMissionLoad();
public DeliveryMissionLoad()
{
	new Float:X,Float:Y,Float:Z;
	new Val[128],comment[64];
	new Valid;
	new File:fDeliveryMissions=fopen("DeliveryMissionPositions.txt",io_readwrite);
	for(new z=0;z<DeliveryMissionLocationsMAX;z++)
	{
		fread(fDeliveryMissions,Val);
		if(sscanf(Val,"fffz",X,Y,Z,comment))
		{
				SendClientMessage(playerid,MSGFAIL_COLOR,"Invalid Position detected, skipping Line.");
		}
		else
		{
			DeliveryMissionPosition[Valid][0]=X;
			DeliveryMissionPosition[Valid][1]=Y;
			DeliveryMissionPosition[Valid][2]=Z;
			DeliveryMissionPickupOwner[Valid]=comment;
			Valid++;
		}
	}
	fclose(fDeliveryMissions);
	DeliveryMissionLocations=Valid;
	new string[128];
	format(string,sizeof(string),"%d Delivery-Mission Positions Loaded.",Valid);
	SendClientMessageToAll(MSGDBUG_COLOR,string);
	for(new M=0;M<DeliveryMissionLocations;M++)
	{
		DeliveryMissionPickup[M]=CreateDynamicPickup(1575,23,DeliveryMissionPosition[M][0],DeliveryMissionPosition[M][1],DeliveryMissionPosition[M][2],-1,0,-1,100);
	}
	return 1;
}
almost done - the start callback simply calculates 2 spots, and sets your variables. it needs to be changed so more players can do a delivery at a time
Code:
forward DeliveryMissionStart(playerid);
public DeliveryMissionStart(playerid)
{
	new RndBegin=random(DeliveryMissionLocations);
	
	//this line makes sure that you wont deliver from a spot to the same one...
	new RndEnd=(1+RndBegin+random(DeliveryMissionLocations-1))%DeliveryMissionLocations;
	
	DeliveryStart[0]=RndBegin; // instead of [0] you could put playerid? thats the idea)
	DeliveryEnd[0]=RndEnd;
	DeliveryBounty[0]=10000;

	SetPVarInt(playerid,"DeliveriesRunning",1);
	new string[128];
	format(string,sizeof(string),"You started a Delivery Mission");
	SendClientMessage(playerid,MSGINFO_COLOR,string);
	format(string,sizeof(string),"Pickup @: %s - Deliver @: %s",DeliveryMissionPickupOwner[DeliveryStart[0]],DeliveryMissionPickupOwner[DeliveryEnd[0]]);
	SendClientMessage(playerid,MSGINFO_COLOR,string);
	return 1;
}
the file "GTA Server/scriptfiles/DeliveryMissionPositions.txt" will hold the positions and the location "owner" of each pickup - create the filewith notepad and paste that positions into it. save.
Code:
2867.2937 2575.7573 10.8203 LV Creek Mall
2593.6128 2293.8923 10.8203 LV VRock Hotel
1711.1775 2206.5674 10.8203 LV SteakHouse Redsands West
1461.4989 2819.1440 10.8203 LV Yellow Bell Golf Course
1468.4546 1013.9830 10.8203 LVA Freight Depot
1663.5665 727.3442 10.8203 LV Randolph Industrial Estate
837.2316 867.5941 13.0157 LV Hunter Quarry
-293.8094 1537.2175 75.5625 LV Big Ear
-158.5596 1221.6477 19.7422 LV Fort Carson Donut Shop
-852.6100 1547.9805 23.6780 LV The Smokin' Beef Grill
-896.0666 1991.0236 60.9141 LV Sherman Dam
-27.5397 2346.2351 24.1406 LV Snake Farm
-318.0117 2659.3611 63.8692 LV Zacker's Feed & Seed
-741.5630 2750.1929 47.2272 LV Valle Ocultado Gas Shop
since you want to /save positions yourself, i presume you know how /save <comment> a position...

as i just started that mission thing, it needs a lot of development. you can only run 1 mission at a time (the [0] array). if another player enters /delivery, he will screw up yours. i hope this helps a bit anyways...

edit2: i forgot to mention the pickup types. use type 14 for being able to pick it up inside a car/truck
edit: if you wonder why i used the small little packs and why iam using pickups: heres the honest answer:
COZ CHECKPOINTS ARE FUCKING UGLY
Reply
#6

I tried this and received the following errors,
Code:
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(621) : error 017: undefined symbol "playerid"
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(651) : error 017: undefined symbol "DeliveryStart"
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(651) : warning 215: expression has no effect
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(651) : error 001: expected token: ";", but found "]"
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(651) : error 029: invalid expression, assumed zero
C:\Users\test\Desktop\Tragic Trucking\gamemodes\trucking3.pwn(651) : fatal error 107: too many error messages on one line
Now, i know the for the DeliveryStart error it should be as easy as new DeliveryStart; or something but i'm not sure the if that's all or not...
Reply
#7

you are right, i forgot 3 variables holding the start and end point ( OnGamoModeInit() ), here they are:
Code:
new DeliveryStart[10];
new DeliveryEnd[10];
new DeliveryBounty[10];
Reply
#8

Ok, i got it to compile and everything... now when i start it says file not found, i do have the file in the scriptfiles folder so i'm puzzled by why it's saying that it says my gamemode is not found
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)