Pickup keep respawning...
#1

Hi, I made a little job for a driver who has to bring peolpe from one place to another, to do so I used pickups...

In this script there are 3 pickups made for this job creation.
Startworkpickup: When the player enters this pickup his job will start (works)
traviswork1: When the player enters this one, he has picked up his client to bring him to another place (does not work)
traviswork2: When the player enters this one, the job is done

So yeah the second pickup doesn't work...
When I enter it, it keeps respawning... so I keep getting the message that I have to bring him to a place...
Please help me...
also there is a little textdraw creation wich should spawn when enterring pickup startwork, but it only shows when the player enters pickup traviswork1...

Code:
new vehicle;
    vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
	
    if(pickupid == startworkpickup)
	{
 		if(vehicle == 516)
   		{
   		    DestroyPickup(startworkpickup);
    		SetPlayerMapIcon( playerid, 2, 334.4390,-1519.8026,35.7015, 55, 0, MAPICON_GLOBAL );
 		   	GameTextForPlayer(playerid,"~w~ Job Lvl 1~g~ :Travis Pastrana is going to participate the X-games",4000,3);
 		   	SendClientMessage(playerid, COLOR_YELLOW, "|-Check the map to see the point where to go. -|");
 		   	IsWorking[playerid] = 1;
 		   	FinishedTask1[playerid] = 1;//he entered the pickup

 		   	traviswork1 = CreatePickup(1254, 14, 334.4390,-1519.8026,35.7015, -1);

 		   	//De Textdraw
 		   	TextDrawShowForPlayer(playerid,Opdracht);
 		   	Opdracht = TextDrawCreate(4.000000,435.000000,"~w~Bring ~y~ Travis Pastrana ~w~ From ~b~His hotel~w~ To ~g~The stadion!");
			TextDrawFont(Opdracht,1);
			TextDrawColor(Opdracht,0xFFFFFFAA);
			TextDrawLetterSize(Opdracht,0.4,1);
			TextDrawSetOutline(Opdracht,1);
			TextDrawSetShadow(Opdracht,0);
			TextDrawSetProportional(Opdracht,1);
			TextDrawBackgroundColor(Opdracht,0x000000ff);
			TextDrawUseBox(Opdracht, 1);
			TextDrawBoxColor(Opdracht, 0x2C2727AA);
			return 1;
		}
	}
	else if(pickupid == traviswork1)
 	{
 		if(vehicle == 516)
		{
  			if(IsWorking[playerid] == 1)
   		    {
   		        if(FinishedTask1[playerid] == 1)
   		    	{
              		DestroyPickup(traviswork1);
	  		        GameTextForPlayer(playerid,"~w~ You picked him up.~g~bring him to the stadium",4000,3);
       		   		SendClientMessage(playerid, COLOR_YELLOW, "|-Check the map to see the point where to go. -|");
	  		        RemovePlayerMapIcon( playerid, 2 );
	  		        SetPlayerMapIcon( playerid, 2, 2732.6616,-1841.6346,9.9145, 55, 0, MAPICON_GLOBAL );
	  		        
	  		        FinishedTask2[playerid] = 1;//he entered the pickup
	  		        FinishedTask1[playerid] = 0;

					traviswork2 = CreatePickup(1254, 14, 2732.6616,-1841.6346,9.9145, -1);
					return 1;
				}
			}
		}
		else
		{
			GameTextForPlayer(playerid,"~r~ ERROR: ~w~You are not in the right vehicle for this mission!",4000,3);
		}
	}
	else if(pickupid == traviswork2)
	{
	    if(vehicle == 516)
	    {
            if(IsWorking[playerid] == 1)
	        {
	            if(FinishedTask2[playerid] == 1)
   		    	{
		            DestroyPickup(traviswork2);
		            new string[128];
		            GameTextForPlayer(playerid,"~w~ Mission accomplished!",4000,3);
	  		        SendClientMessage(playerid, COLOR_GREEN, "-U have been given $1500 for completing a level 1 mission.-");
	  		        RemovePlayerMapIcon( playerid, 2 );
	  		        TextDrawHideForPlayer(playerid, Opdracht);
					GivePlayerMoney(playerid,1500);
					startworkpickup = CreatePickup(1254, 14, 669.7355,-1275.9504,13.4609, -1);

	  		        FinishedTask2[playerid] = 0;
	  		        FinishedTask1[playerid] = 0;
					new mrand =random(500);
					format(string,sizeof(string),"-Travis has given u $%d as a little bonus!-",mrand);
					SendClientMessage(playerid,COLOR_GREEN,string);
					GivePlayerMoney(playerid,mrand);
					
					SendClientMessage(playerid, COLOR_SEXYGREEN, "-Mission accomplished, wanna go back to your base and do another mission? type /home.-");
				}
			}
		}
		else
		{
		    GameTextForPlayer(playerid,"~r~ ERROR: ~w~You are not in the right vehicle for this mission!",4000,3);
		}
	}
//other code
Reply
#2

traviswork1 or traviswork2 ? which one doesn't work ?
Reply
#3

traviswork1
but I can't test if traviswork2 works, because I have to pass traviswork1 first, wich does not work :/
Reply
#4

let me guess:
you created the mission with the "start" pickup and the "target" pickup, it worked well.
then you created the second part, where to pickup the passanger. theres your little mistake.
pay attention at the
Code:
					if(FinishedTask1[playerid] == 1)
inside your first (spamming) pickup part. shouldnt it set the value to 1?
or can it be that another player is using the pickups too, since theyre all global?
edit: i need to read it again >-<
why are you using the FinishedTask_[playerid] variables? i guess when 1 pickup only exists, it can trigger 1 action only?
Reply
#5

double post 2/2:
nvm all that. i maybe found the bug. your script looks fine! its obvious that you added the FinishedTask variables to make SURE everything will work fine. good idea, BUT theres a little problem...

create a pickup:
BabulsPickup=Createblabla(). that BabulsPickup, when formatted in a "%d", could return 1, the first pickup by SAMP (its index).
now destroy my BabulsPickup...
Destroyblabla(BabulsPickup);
and create another one:
KnackworstPickup=Createblabla().
its index will be the SAME as the BabulsPickup, which got created earlier.
solution:
Code:
[pseudocode]
#define ProgressMissionStart=1;
#define ProgressMissionPassangerPickup=2;
#define ProgressMissionPassangerDeliver=3;
new PickupType[maxplayers];//create an array to store 1 of this values, pointed by each pickupid:

KnackworstPickup=Createblaba();
PickupType[KnackworstPickup]=ProgressMissionStart;

if(PickupType[KnackworstPickup]==ProgressMissionStart)
{blabla}

[/pseudocode]
/curse that:
Code:
startworkpickup==traviswork1==traviswork2==0;
i hope it helps!

offtopic: i <3 to edit! and somtimes i fail - lol sry, removed 2x the sig now. space restored ^^
Reply
#6

uhm... wat!?
Reply
#7

erm.. if you create a pickup called MissionPU1.. what does the native return? the pickupID for MissionPU1. lets assume 123 (you created 122 pickups earlier). then create another pickup, MissionPU2, which will get the pickupID 124. destroy the MisisonPU1 pickup, the slot for pickupID 123 will be free for the next pickup being created...
Code:
MissionPU1= 123
MissionPU2= 124
destroy MissionPU1
MissionPU3= 123
etc... if you didnt create ANY pickups earlier, your "profile" would look like
Code:
startworkpickup = 0
destroy startworkpickup
traviswork1 = 0
destroy startworkpickup
traviswork2 = 0
you see that your pickup check basically does this:
Code:
if (pickupid==0)
.. which is true in each case.
my suggestion:
#define some Values like 3 mission "progresses", and
store this #defined variable in a PVar or your global [MAX_PLAYERS] variable, it wont matter.
you can check it out for yourself (makes sense then). add it as first oin your OnPlayerPickup:
Code:
new debugstring[64];
format(debugstring,sizeof(debugstring),"Pickup ID: %d",pickupid);
SendClientMessage(playerid,0xcc3333ff,debugstring);
... it will show you the same pickup id!
you need to store the mission progress in a global variable for a player, dont depend on the pickupid.
Reply
#8

hmm ok it's still kinda hard for me, since i'm a beginner but what if I just delete the misisonworkprogress, then it will work?

also u say this:
Code:
startworkpickup = 0
destroy startworkpickup
traviswork1 = 0
destroy startworkpickup
traviswork2 = 0
but it's a variable right? so I have to make 'new pickup[playerid]' for all the pickups I create for my jobs?
Reply
#9

Ok, so after rewieving your first solution and pretty much understanding it, i implented it but now I get this:

Code:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(2079) : error 017: undefined symbol "ProgressMissionStart"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(2237) : error 017: undefined symbol "ProgressMissionStart"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
error lines
1:
Code:
PickupType[startworkpickup]=ProgressMissionStart;
2:
Code:
    if(PickupType[startworkpickup]==ProgressMissionStart)
:/
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)