Game Modding | Call of Duty: Black Ops 3 | Scripting
D_v_z:
Can someone please tell me how to spawn a key for a door at random locations in the map? Help would be appreciated :)
Brodie3750:
Also interested
Spiki:
D_v_z:
D_v_z:
Spiki:
show me the original code you're using and ill help you put it in.
the code i wrote just picks a random struct and spawns a script_model there so you'd put that where you probable have key = getent(...)
D_v_z:
show me the original code you're using and ill help you put it in.
the code i wrote just picks a random struct and spawns a script_model there so you'd put that where you probable have key = getent(...)
Spiki:
In mapname.gsc:
function init_keycard()
{
level.key_obtained = false;
key = GetEnt( "key_trigger", "targetname" );
key SetCursorHint( "HINT_NOICON" );
key SetHintString( "Press and Hold ^3&&1^7 to Pick Up Key" );
key thread wait_for_pickup();
key_doors = GetEntArray( "key_door", "targetname" );
foreach( door in key_doors )
{
door SetCursorHint( "HINT_NOICON" );
door SetHintString( "A Key is Required to Open the Door" );
door thread wait_for_unlock();
}
}
function wait_for_pickup()
{
self waittill( "trigger", player );
model = GetEnt( self.target, "targetname" );
model delete();
self delete();
level.key_obtained = true;
iprintlnbold( "The Key Has Been Obtained" );
}
function wait_for_unlock()
{
level endon( "intermission" );
while( !level.key_obtained )
wait(0.25);
self SetHintString( "Press and Hold ^3&&1^7 to Unlock Door" );
self waittill( "trigger", player );
models = GetEntArray( self.target, "targetname" );
PlaySoundAtPosition( "zmb_cha_ching", player.origin );
spawn_flag = models[0].script_flag;
flag::set( spawn_flag );
wait(0.05);
foreach( model in models )
model delete();
self delete();
}
That's the code I'm using.
could you help me with making it spawn in as many locations as I want to use?
I don't know yet how many Locations I'm gonna pick XD.
BTW Thanks for helping man, really appreciate it!
D_v_z:
I tried this but it didn't work yet :( maybe I did something wrong?
I put the xmodel name in the zone file, I completely pasted over the previous script, and I added the kvp's.
Here are some pictures from radiant:
and this is the code from you that I'm using with my model in it:
#define KEY_MODEL "z1_props_power_key"
#precache( "model", KEY_MODEL);
function init_keycard()
{
//CHOOSING A SPAWN POINT
key_spots = struct::get_array("key_spot", "targetname"); //all possible spots
location = array::random(key_spots); //spot where the key will spawn
//SPAWNING THE MODEL
key = Spawn("script_model", location.origin);
key.angles = location.angles;
key SetModel(KEY_MODEL);
//SPAWNING A TRIGGER
trig_width = 128;
trig_height = 64;
trig = Spawn("trigger_radius_use", key.origin, 0, trig_width, trig_height);
trig SetCursorHint("HINT_NOICON");
trig SetTeamForTrigger("allies");
trig SetHintString("Press and Hold ^3&&1^7 to Pick Up Key");
//PREPPING DOORS
door_trigs = GetEntArray( "key_door", "targetname" );
foreach( door in door_trigs )
{
door SetCursorHint( "HINT_NOICON" );
door SetHintString( "A Key is Required to Open the Door" );
door thread wait_for_unlock();
}
//WAITING FOR TRIGGER
trig waittill("trigger", player);
trig Delete();
key Delete();
//i rather do a notify than a variable and a while loop.
//also works better if you want to work with multiple entities
level notify("key_obtained");
IPrintLnBold( "The Key Has Been Obtained" );
}
function wait_for_unlock()
{
level waittill("key_obtained"); //wait for the notify
self SetHintString( "Press and Hold ^3&&1^7 to Unlock Door" );
self waittill( "trigger", player );
PlaySoundAtPosition( "zmb_cha_ching", player.origin );
//idk tf you were doing here. prob trying to open a zone
/*
spawn_flag = models[0].script_flag;
flag::set( spawn_flag );
*/
if(isdefined(self.script_flag))
level flag::set(self.script_flag); //put script_flag kvp on trigger like for doors
wait(0.05);
models = GetEntArray( self.target, "targetname" );
foreach( model in models )
model Delete();
self Delete();
}
In-game there is no key model or trigger at the script struct location, and the door says: "press x to open" immediately.
Maybe you know why it's not working?
Spiki:
🤦♂️
also structs are targetname on the left, key_spot on the right (not keyspot)
D_v_z:
🤦♂️
also structs are targetname on the left, key_spot on the right (not keyspot)
Spiki:
Thanks for all the effort in making the script man! really appreciate it!
Unfortunely if I change the script struct targetname to key_spot it crashes to the menu straight away giving a registration error.
And I didn't write the key script. I got it from a forum.
I don't understand scripting language so that is why I make mistakes like this :cautious:
D_v_z:
what error. post pic
also protip:
if you give your struct the kvp model - *model name*
it will show *model name* instead of the struct so you can place it better
*model name* is the name of the model, dont write that in exactly like you did for the door XD
Spiki:
Thanks for the tip XD,
So I did make a new map for testing with this script and structs, etc, and now it doesn't give me the error. but at the script structs the model won't show up and also there's no trigger at that spot. and the door says not available. So maybe I can put the map file and script online and if you want you can see for yourself why it's not working?
could save us alot of time here XD
I'll put it on my google drive (I made it drag and drop): https://drive.google.com/drive/folders/11zwxvxqTz8u9SCgiHcWJVt6no6tZ8xOL?usp=sharing
D_v_z:
its locked
Spiki:
Protip: dont upload the zone folder in usermaps/mapname, it's just compiled files and its hella big. Zone_source is useless aswell. So is english and in this case sound folders.
Triggers cant go around brushes. They wont work then. You need 2 triggers, one on each side of the door. I don't think it's a problem with models like in the testmap. The reason it says unavailable is because you didn't call the function. (chack below)
This is how struct models work:
Also i see why nothing works.
You didn't call the function init_keycard.
It's done like so:
That should be it. Didn't test tho. You can put some prints in to see what's going on like so:
D_v_z:
Protip: dont upload the zone folder in usermaps/mapname, it's just compiled files and its hella big. Zone_source is useless aswell. So is english and in this case sound folders.
Triggers cant go around brushes. They wont work then. You need 2 triggers, one on each side of the door. I don't think it's a problem with models like in the testmap. The reason it says unavailable is because you didn't call the function. (chack below)
This is how struct models work:
Also i see why nothing works.
You didn't call the function init_keycard.
It's done like so:
That should be it. Didn't test tho. You can put some prints in to see what's going on like so:
ThomassOind:
Во области беттинга букмекерская учреждение 1overcome
ранее фаланга возраст берет для себя ставки в спорт действия
также дает инвесторам хорошую подпись, отличные коэффициенты 1win скачать
также подвижное дополнение. В Том Числе И в малом телефоне,
пребывание присутствии устойчивого силок интернет,
прибавление станет функционировать. Чтобы Того Воеже совершать
мониторинги в обожаемые выдержки, абонент обязан собирать
видеоигровой акк.