Game Modding | Call of Duty: Black Ops 3 | Scripting
ModmeBot:
Thread By: Wild
Hello, over the past few days I have been learning how to script. I successfully made a script that added little credits in the bottom corner of the screen. I decided to test myself and try and put together something a bit more difficult. I am trying to create a script that allows me to shoot an object, and in return I would get Jugg. Again I am new to scripting and I am just trying to learn so please be nice lol.
Basically since I am trying to learn I don't need people to actually make the script the for me, rather I would like them to help explain to me what I did wrong and what needs to be changed. If it not a problem it would be great if you guys could explain why what I have is wrong and why the other ways are correct. I am not trying to make this script to actually use, it's just simply to help me learn and understand how to script so again, I am looking for explanations, not someone to make a script.
Here is what I did.
1) First I added "#insert scripts\zm\_zm_perks.gsh;" with the other #using lines of text at the top of my mapname.gsc.
2) Underneath "zm_usermap::main();" I added "level shoot_for_jugg();"
3) Finally, this is the script I wrote at the bottom of my mapname.gsc:
function shoot_for_jugg()
{
trigs = GetEntArray( "trig_for_jugg", "targetname" );
foreach( trig in trigs )
trig thread trig_shot();
}
function trig_shot()
{
self waittill( "trigger", player );
player PlayLocalSound( "zmb_cha_ching" ); //I don't know the alias name for any other sounds so is simply a placeholder
self delete_model();
}
function delete_model()
{
bears = GetEntArray( "give_jug_model", "targetname" );
foreach( bear in bears )
bear delete();
thread give_jugg();
}
function give_jugg()
{
players = GetPlayers();
foreach( player in players )
{
perk = GetPerks( "PERK_JUGGERNOG" );
player GivePerks( perk );
}
}
ModmeBot:
Reply By: Abnormal202
The problem is in how you referenced it. You typed:
level shoot_for_jugg();
level thread shoot_for_jugg();
ModmeBot:
Reply By: Wild
Abnormal202
The problem is in how you referenced it. You typed: level shoot_for_jugg(); when you should've threaded it: level thread shoot_for_jugg(); because you didn't thread it, it would be causing the game to get stuck on that script, before anyone has even loaded in.
function give_jugg()
{
players = GetPlayers();
foreach( player in players )
{
player SetPerk( "PERK_JUGGERNOG" );
}
}
ModmeBot:
Reply By: Wild
FIXED:
Huge thanks to Abnormal and Jerri for helping me to get this working. Looking at it now I kind of understand how it works. Thanks guys