Home   Help Search Login Register  

Author Topic: Create marker? Possible?  (Read 926 times)

0 Members and 1 Guest are viewing this topic.

Durbs

  • Guest
Create marker? Possible?
« on: 01 Dec 2005, 22:58:46 »
I was wondering if it is possible to use a camcreate or createvehicle command to create a marker on the map? Let me explain a lil better....

My mission has a lightfactory to build transports....and all that krunk is already scripted and working...however I would like it so that when it creates the vehicle for the player....it also creates a little yellow "dot" marker that follows the vehicle until it's destroyed....then the dot marker should become a red X, and finally dissapear.

Im sure if you've ever played mfcti you will know what im talking about. Mfcti uses predefined markers on the map that are assigned to vehicles as they are built....but I couldn't really make sense of what mr.melvin was doing.  ???

lol - the more i explain the more confusing it gets  :P Anyway - u should have a basic idea of what im trying to do. Green hit for whoever can answer this first!

 Thx in advance  :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Create marker? Possible?
« Reply #1 on: 01 Dec 2005, 23:13:28 »
You cannot create a marker, but you can put one on the map that is invisible and then make it visible later.

Put the marker on the map and give it a name - select the type 'Empty'.  Then in the mission when you want it to be visible set it to be a dot as follows:
"markername" SetMarkerType "Dot"

Check out setMarkerPos to move the marker
http://www.ofpec.com/editors/comref.php?letter=S#setMarkerPos
and setMarkerColor to change its colour:
http://www.ofpec.com/editors/comref.php?letter=S#setMarkerColor

I can't remember the name of the cross marker.  Just put one on an empty mission and save it, then go into mission.sqm to find what it is called.
« Last Edit: 01 Dec 2005, 23:49:12 by THobson »

Durbs

  • Guest
Re:Create marker? Possible?
« Reply #2 on: 02 Dec 2005, 01:42:13 »
thanks THobson - but i think you misunderstood my objective.....the reason i did not want to use a predifined marker(one placed in map via ingame-editor) is due to the uncertainty of how many times it will be used....

In other words.... I don't know if a player will use the lightfactory to create a vehicle once...or 20 times...how can i assign each new vehicle created with it's own marker?

And even if i placed 50 markers on the map....the createvechile script would assign the SAME marker to each NEW vehicle created....leaving the previous one unmarked...no?

I don't believe it's possible to use one predef. marker into duplicate markers....hence my delema!

I will look at the Mfcti summore...but that caliber scripting is a bit beyond my current abilities.
I also checked out Marker_effects by General Barron, but that uses predefined markers!  :o

Hopefully there is an answer to this fookingshiiat!
Thx again in advance for any help. :D
« Last Edit: 02 Dec 2005, 01:45:27 by ÐurbanPoisonâ„¢ »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Create marker? Possible?
« Reply #3 on: 02 Dec 2005, 03:29:12 »
Quote
And even if i placed 50 markers on the map....the createvechile script would assign the SAME marker to each NEW vehicle created....leaving the previous one unmarked...no?

ahh.. quite a dilema, but which can be fixed using the call and format commands, and a global variable.
(the call and format command are in the comref if you don't know what they do - don't have a link ATM)

andwho....
in your init.sqs define a variable (we'll call it counter)
Code: [Select]
counter = 0
then name all your (we'll say 50 for this example) 50 markers marker0 - marker49

then, to select your markers in your script run this code:
Code: [Select]
call format [{_marker = "marker%1"},counter]
counter = counter + 1
?counter == 50:counter = 0

and then do the changing of the marker and moving it and all that using the _marker variable
to be safe you may want to use more than 50 markers, but it depends on the situation

EDIT: k here are the links:
Format
Call - *check the second one*
« Last Edit: 02 Dec 2005, 03:34:16 by Triggerhappy »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Create marker? Possible?
« Reply #4 on: 02 Dec 2005, 09:14:16 »
Also a brute force method is to put in a couple of hunderd markers, put their names in an array and then each time you need one select the next one.

Durbs

  • Guest
Re:Create marker? Possible?
« Reply #5 on: 03 Dec 2005, 10:04:13 »
So I tried TriggerHappy's Idea...but I think I fooked up sumhow.  :'(

As it stands now - I have 50 markers on the map...named marker0 - marker49, and then
the "buy jeep" script that calls the markers. (Or should anyway lol)

Please forgive my poor script-writing, I have very severe ADD  :o

Code: [Select]
?(side player==west):goto "unlock";
exit;

#unlock
?!(Count Units player < 11) : goto "fullteam";
_j = "Jeep" createvehicle getpos player;
jeep = nearestobject [player,"jeep"];

_marker = [marker0, marker1, marker2, marker3,marker4, marker5, marker6, marker7, marker8, marker9, marker10, marker11, marker12, marker13,marker14, marker15, marker16, marker17, marker18, marker19, marker20, marker21, marker22, marker23,marker24, marker25, marker26, marker27, marker28, marker29, marker30, marker31, marker32, marker33,marker34, marker35, marker36, marker37, marker38, marker39, marker40, marker41, marker42, marker43,marker44, marker45, marker46, marker47, marker48, marker49]
call format [{_marker = "marker%1"},counter]
counter = counter + 1
?counter == 49:counter = 0
Player Groupchat "Jeep is ready!";
#loop
_marker setmarkerpos getpos jeep;
~2
?!(alive jeep): goto "dead";
goto "loop"
#dead
?!(alive jeep): "_marker" Setmarkertype "marker" and "_marker" setmarkercolor "ColorGreen";
Player Groupchat "A Jeep has been destroyed!";
~30
deleteVehicle jeep;
Exit;

#fullteam
Player Groupchat "Cannot create Jeep, your squad is at maximum capacity.";
exit;

The ^^ result is a marker being assigned to jeep after it's built...but as soon as the next jeep is built and next marker is assigned.....it dissapears from the first jeep built. But - the 2nd jeep will now have 2 markers following it. (1 slower than the next/maybe cause of loop?) and the next jeep built does the same thing and so on and so on.

So...can you tell where i f%#ked up?  ::)
Thx again for anyhelp u can offer.

LoTekK

  • Guest
Re:Create marker? Possible?
« Reply #6 on: 03 Dec 2005, 10:33:54 »
As far as I can tell, with each iteration, you're assigning the most recently-created jeep to the global variable "jeep"
Code: [Select]
jeep = nearestobject [player,"jeep"];Which would explain why all the markers follow the most recent jeep.

What I'd do is make use of the same counter you're using to increment the marker number, and do the same with the jeeps.
Actually, scratch that. Just use "_jeep" instead of "jeep"

One quick note, and I'm not entirely certain I'm correct (I sometimes have trouble with array ops), but it seems redundant that you're defining "_marker" as an array of all possible marker numbers, and then on the next line assigning the same variable as the current marker. Is the initial assignment even necessary?
« Last Edit: 03 Dec 2005, 10:35:24 by LoTekK »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Create marker? Possible?
« Reply #7 on: 03 Dec 2005, 14:50:23 »
no it isn't, and lotekk is right in saying that jeep should be _jeep
also, this line:
Code: [Select]
?counter == 49:counter = 0should be:
Code: [Select]
?counter == 50:counter = 0otherwise you'll never use the last marker.

so, the whole thing, with the revisions:

------------------------------------------------------------------------------------------
?(side player==west):goto "unlock"
exit

#unlock
?!(Count Units player < 11) : goto "fullteam"
"Jeep" createvehicle getpos player
_jeep = nearestobject [player,"jeep"]

call format [{_marker = "marker%1"},counter]
counter = counter + 1
?counter == 50:counter = 0
Player Groupchat "Jeep is ready!"
_marker setmarkertype "dot"
 _marker setmarkercolor "ColorRed"

#loop
_marker setmarkerpos getpos jeep
~2
?!(alive jeep): goto "dead"
goto "loop"
#dead
?!(alive jeep): _marker Setmarkertype "marker" and _marker setmarkercolor "ColorGreen"
Player Groupchat "A Jeep has been destroyed!"
~30
deleteVehicle jeep
_marker setmarkertype "empty"
Exit

#fullteam
Player Groupchat "Cannot create Jeep, your squad is at maximum capacity."
exit
-----------------------------------------------------------------------------------------------

the bold are all things i changed
the 2 setmarkertype things are t make markers reuseable

Durbs

  • Guest
Re:Create marker? Possible?
« Reply #8 on: 03 Dec 2005, 23:53:13 »
Well - I just tested and nothing happens now lol  ::)

No marker when jeep is created...and no msg of cleanup after jeep is destroyed! AAArrrgghh!

If "jeep" was changed to "_jeep".....shouldn't the rest of the script refering to "jeep" also be changed to "_jeep"?

Maybe you can tell... I have very little grasp on HOW and WHY scripts do what they do, everything I learned was the hard way, but looking at code and trying to decrypt it. So pls forgive my ignorance  :-X

Anyway - I'm stoked to get this to work. I know it's possible :)
Thanks guys - the past 2 weeks here at ofpec has saved me many hours of pain! Ya'll rule  ;D If u ever in Seattle I'll buy ya a beer :)
« Last Edit: 04 Dec 2005, 00:08:55 by ÐurbanPoisonâ„¢ »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Create marker? Possible?
« Reply #9 on: 04 Dec 2005, 02:40:05 »
ahh yes, i forgot to add the underscores to all the jeeps
do that and it should work

Durbs

  • Guest
Re:Create marker? Possible?
« Reply #10 on: 04 Dec 2005, 03:37:31 »
Firstly - thanks trigger for your help :D
Secondly - Bahumbug! Still no luck!  :'(

I changed the "jeep" to "_jeep" on all relevant spots...but to no avail! It creates the jeep with no probs - but there's no marker on the jeep. Then after the jeep is destroyed, I get a marker error(See Attachment). The jeep destroyed message played and the jeep deleted.
Here is the script as it stands:
________________________________________

?(side player==west):goto "unlock"
exit

#unlock
?!(Count Units player < 11) : goto "fullteam"
"Jeep" createvehicle getpos player
_jeep = nearestobject [player,"jeep"]

call format [{_marker = "marker%1"},counter]
counter = counter + 1
?counter == 50:counter = 0
Player Groupchat "Jeep is ready!"
_marker setmarkertype "dot"
_marker setmarkercolor "ColorGreen"
#loop
_marker setmarkerpos getpos _jeep
~2
?!(alive _jeep): goto "dead"
goto "loop"
#dead
_marker Setmarkertype "marker" and _marker setmarkercolor "ColorGreen"
Player Groupchat "A Jeep has been destroyed!"
~30
deleteVehicle _jeep
_marker setmarkertype "empty"
Exit

#fullteam
Player Groupchat "Cannot create Jeep, your squad is at maximum capacity."
exit
________________________________________

Not sure why it ain't working - everything seems in order. Oh, 1 question about the counter.
Shouldn't it have to say that counter is a PublicVariable? And If so, do i state it everytime? Or just in the Init?

ie:
counter = counter + 1
PublicVariable "counter"

Anyway - I will tweak it summore and see what i figure. again, if any1 can help..... ;D
« Last Edit: 04 Dec 2005, 04:15:01 by ÐurbanPoisonâ„¢ »

Durbs

  • Guest
Re:Create marker? Possible?
« Reply #11 on: 04 Dec 2005, 09:05:21 »
Yay! Got it to work.

Quote
it seems redundant that you're defining "_marker" as an array of all possible marker numbers, and then on the next line assigning the same variable as the current marker. Is the initial assignment even necessary?
^^was where it was confused.  
I removed the second variable and switched all the jeep+_jeep to _j.
Yay! Thanks again for all your help - really made all the dif :)
Below is a fixed example mission.