SA-MP Forums Archive
Help with MiniMission! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with MiniMission! (/showthread.php?tid=165081)



Help with MiniMission! - Desertsoulz - 03.08.2010

My minimission is not working, the checkpoints and stuff is fine, but when you go back to the Trash Company, it doesn't give the cash, can someone tell me what the problem is.

Код:
//------------------------------------------------------------------------------
//
//   Trash Master miniMission Filter Script v1.0
//   Designed for SA-MP v0.3
//
//   Created by Desertsoulz
//
//
//   Original Script from Pizza Boy miniMission Filterscript v1.0
//   Designed for SA-MP v0.2
//
//   Created by zeruel_angel
//
//------------------------------------------------------------------------------

#include <a_samp>
enum posicion{
	Float:X,
	Float:Y,
	Float:Z
	}
new Destinations[100][posicion];
new TrashCompany[20][posicion];
new archDestinations[]="TrashMaster1.txt";
new archTrashCompany[]="TrashMaster2.txt";
new contador[MAX_PLAYERS];

new playerInMiniMission[MAX_PLAYERS];
new avisado[MAX_PLAYERS];
new cantidadDestinations;
new cantidadTrashCompany;

forward terminateMission(playerid);

public OnFilterScriptInit()
	{
	print("\nTashMaster Filter Script v1.0 Loading...\n******************************\n      Desertsoulz\n");
	new File:fileTrash;
	new lineaTrash[255];
	fileTrash = fopen(archDestinations,io_readwrite);
	new j=0;
	new idx;
 	while	((fread(fileTrash,lineaTrash,sizeof(lineaTrash),false))&&(j<25))
			{
			idx = 0;
			Destinations[j][X] = floatstr(strtok(lineaTrash,idx));
			Destinations[j][Y] = floatstr(strtok(lineaTrash,idx));
			Destinations[j][Z] = floatstr(strtok(lineaTrash,idx));
			j++;
			}
	cantidadDestinations=j;
	fclose(fileTrash);
	format(lineaTrash,sizeof(lineaTrash),"Total destinations loaded: %d", cantidadDestinations);
	print(lineaTrash);

    fileTrash = fopen(archTrashCompany,io_readwrite);
	j=0;
 	while	((fread(fileTrash,lineaTrash,sizeof(lineaTrash),false))&&(j<25))
			{
			idx = 0;
			TrashCompany[j][X] = floatstr(strtok(lineaTrash,idx));
			TrashCompany[j][Y] = floatstr(strtok(lineaTrash,idx));
			TrashCompany[j][Z] = floatstr(strtok(lineaTrash,idx));
			j++;
			}
	cantidadTrashCompany=j;
	fclose(fileTrash);
	format(lineaTrash,sizeof(lineaTrash),"Total Trash Companies loaded: %d", cantidadTrashCompany);
	print(lineaTrash);
	for (new i=0;i<MAX_PLAYERS;i++)
	    {
     	playerInMiniMission[i]=-1;
    	avisado[i]=-1;
	    }
    print("TrashMaster Filter Script fully Loaded\n**********************************\n\n");
	}

public OnFilterScriptExit()
	{
    print("\n**********************\n*TrashMaster Script UnLoaded*\n**********************\n");
	return 1;
	}
//------------------------------------------------------------------------------------------------------
strtok(const string[], &index)
	{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
		{
		index++;
		}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
		{
		result[index - offset] = string[index];
		index++;
		}
	result[index - offset] = EOS;
	return result;
	}
//------------------------------------------------------------------------------------------------------
public terminateMission(playerid)
	{
	SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Terminated! Press 2 if you would like to start over.");
    playerInMiniMission[playerid]=-1;
    avisado[playerid]=-1;
    DisablePlayerRaceCheckpoint(playerid);
    contador[playerid]=0;
    return 1;
	}
//------------------------------------------------------------------------------------------------------
public OnPlayerStateChange(playerid, newstate, oldstate)
	{
	if (newstate==PLAYER_STATE_DRIVER)
	    {
	    if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 408)
	        {
	        if 	(avisado[playerid]==-1)
	            {
				SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Press 2 if you would like to begin the TrashMaster Mission.");//SetTimerEx("MandarMensaje",5500,0,"%d",playerid);
				}
			else
			    {
			    KillTimer(avisado[playerid]);
			    avisado[playerid]=-1;
			    }
		    }
	    }
	if 	(newstate==PLAYER_STATE_ONFOOT)
	    {
	    if 	((playerInMiniMission[playerid]>0)&&(avisado[playerid]==-1))
		    {
		    SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: You have 10seconds to find a TrashMaster Truck.");
		    avisado[playerid]=SetTimerEx("terminateMission",10000,0,"%d",playerid);
		    }
	    }
	return 1;
	}
//------------------------------------------------------------------------------------------------------
getNearestTrashCompany(Float:X1,Float:Y1,Float:Z1)
	{
	new index;
	new Float:distOld=9999.0;
	new Float:distNew=0.0;
	for (new i=0;i<cantidadTrashCompany;i++)
	    {
	    distNew=floatsqroot(floatpower(floatabs(floatsub(TrashCompany[i][X],X1)),2)+floatpower(floatabs(floatsub(TrashCompany[i][Y],Y1)),2)+floatpower(floatabs(floatsub(TrashCompany[i][Z],Z1)),2));
	    if 	(distNew<distOld)
	        {
	        distOld=distNew;
	        index=i;
	        }
	    }
	return index;
    }
//------------------------------------------------------------------------------------------------------
TrashCompanyAcasa(playerid)
	{
 	new Float:X1,Float:Y1,Float:Z1;
	GetPlayerPos(playerid,X1,Y1,Z1);
	new index = getNearestTrashCompany(X1,Y1,Z1);
	new index2 = random(cantidadDestinations);
	DisablePlayerRaceCheckpoint(playerid);
	SetPlayerRaceCheckpoint(playerid,0,TrashCompany[index][X],TrashCompany[index][Y],TrashCompany[index][Z],Destinations[index2][X],Destinations[index2][Y],Destinations[index2][Z],3.0);
    playerInMiniMission[playerid]=index2;
	return 1;
	}
//------------------------------------------------------------------------------------------------------
casaATruckCompany(playerid)
    {
	new index2 = playerInMiniMission[playerid];
	new index = getNearestTrashCompany(Destinations[index2][X],Destinations[index2][Y],Destinations[index2][Z]);
	DisablePlayerRaceCheckpoint(playerid);
	SetPlayerRaceCheckpoint(playerid,0,Destinations[index2][X],Destinations[index2][Y],Destinations[index2][Z],TrashCompany[index][X],TrashCompany[index][Y],TrashCompany[index][Z],3.0);
	playerInMiniMission[playerid]=0;
	return 1;
    }
//------------------------------------------------------------------------------------------------------
MissionIni(playerid)
    {
    SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Come to nearest Trash Company!");
    TrashCompanyAcasa(playerid);
    return 1;
    }
//------------------------------------------------------------------------------------------------------
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
	{
	if ((newkeys==KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
	    {
	    if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 408)
	        {
    	    if 	(playerInMiniMission[playerid]<0)
	        	{
	        	MissionIni(playerid);
	        	}
			else
			    {
	            terminateMission(playerid);
			    }
		    }
	    }
	}
//------------------------------------------------------------------------------------------------------
public OnPlayerEnterRaceCheckpoint(playerid)
	{
	if 	(playerInMiniMission[playerid]!=-1)
	    {
     	if (playerInMiniMission[playerid]==1)
     	    {
     	    SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Great! Now go back to the Trash Company!");
			GivePlayerMoney(playerid,20);
			TrashCompanyAcasa(playerid);
			contador[playerid]++;
     	    }
		else
			{
			SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Go get the trash!");
			casaATruckCompany(playerid);
		    }
		}
	return 1;
	}
//------------------------------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid)
	{
	terminateMission(playerid);
	return 1;
	}



Re: Help with MiniMission! - Rolyy - 03.08.2010

Does it or does it not gives you the message of "TrashMaster Mission: Great! Now go back to the Trash Company!"?

Код:
public OnPlayerEnterRaceCheckpoint(playerid)
	{
	if 	(playerInMiniMission[playerid]!=-1)
	    {
     	if (playerInMiniMission[playerid]==1)
     	    {
     	    SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Great! Now go back to the Trash Company!");
			GivePlayerMoney(playerid,20);
			TrashCompanyAcasa(playerid);
			contador[playerid]++;
     	    }
		else
			{
			SendClientMessage(playerid,0xF6970CAA,"TrashMaster Mission: Go get the trash!");
			casaATruckCompany(playerid);
		    }
		}
	return 1;
	}



Re: Help with MiniMission! - Desertsoulz - 03.08.2010

Nope its just the money problem.



Re: Help with MiniMission! - Rolyy - 03.08.2010

What do you mean by "Nope"..?
Does it or Does it Not?
Shows you the message.


Re: Help with MiniMission! - Desertsoulz - 03.08.2010

The message shows, the only problem with this script, is when you go back to the trash company, it doesn't give the cash...


Re: Help with MiniMission! - Rolyy - 03.08.2010

Uhm... Correct me if im wrong but I cannot find the "completing" part of this script..


Re: Help with MiniMission! - Desertsoulz - 03.08.2010

Whats that?


Re: Help with MiniMission! - Rolyy - 03.08.2010

I cannot find the finishing part in this script you posted..


Re: Help with MiniMission! - Desertsoulz - 03.08.2010

Ohhh now I got ya, no its just like single player mini-missions,

you press 2 to activate the mission,

then you go around town going to checkpoints and each checkpoint you recieve cash... 25$ per checkpoint in this script.

to deactivate the mission you press 2 again or leave the vehicle


Re: Help with MiniMission! - Rolyy - 03.08.2010

so its a never ending mission?
Could you give me your IP adress so I could check it out?