Post: array queries
02-14-2016, 10:42 PM #1
seanhellen
Are you high?
(adsbygoogle = window.adsbygoogle || []).push({}); Hey all - i have the following;
    
level.Position["Hijacked"][0] = Spawn things;
level.Position["Hijacked"][1] = Spawn things;
level.Position["Hijacked"][2] = Spawn things;
level.Position["Hijacked"][3] = Spawn things;
level.Position["Hijacked"][4] = Spawn things;
level.Position["Hijacked"][5] = Spawn things;


obviously I'm using this as an example...each one spawns an ammo crate (jwm614's function) in a different position. So I thought this would work;

    
if(Map() == "Hijacked")
{
for(i = 0; i < 5; i++)
===========> {
level.Position["Hijacked"][i];
wait 10;
}
}


Now, I was hoping this would spawn an ammo crate every 10 secs -

Q1 - GSC Studio tells me theres something wrong where I have put the arrow - I am assuming I have done something wrong with the arrays, but I don't know what I have done wrong.

Q2 - How can I delete the crate and associated functions (text prompt to use it and the re-stocking function itself) as I think if I just delete the crate, the prompt and the function would still work, just be no crate there.

Any help appreciated Smile
(adsbygoogle = window.adsbygoogle || []).push({});
02-14-2016, 10:49 PM #2
Originally posted by seanhellen View Post
level.Position["Hijacked"];


I believe the compiler error is coming from this line, as it's doing nothing, I guess the compiler doesn't like that.
Not sure what you're asking with the second question though
02-14-2016, 10:57 PM #3
seanhellen
Are you high?
Originally posted by John View Post
I believe the compiler error is coming from this line, as it's doing nothing, I guess the compiler doesn't like that.
Not sure what you're asking with the second question though


Thought it was...in my mind, it would cylce through 0-5 and spawn the crates that i set out in the first code section. Thought it might have saved me typing out the function several times.

The objective of this to move the ammo crate round the map in the 6 locations set out in the 1st code section, when the 2nd one spawns, it deletes the first, 3rd spawns, it deletes the 2nd, etc.
My problem is how to delete the crate and the re-stocking ammo function that goes with it.
02-14-2016, 11:06 PM #4
jwm614
NextGenUpdate Elite
Originally posted by seanhellen View Post
Thought it was...in my mind, it would cylce through 0-5 and spawn the crates that i set out in the first code section. Thought it might have saved me typing out the function several times.

The objective of this to move the ammo crate round the map in the 6 locations set out in the 1st code section, when the 2nd one spawns, it deletes the first, 3rd spawns, it deletes the 2nd, etc.
My problem is how to delete the crate and the re-stocking ammo function that goes with it.


so u want to spawn an ammo crate then move it around the map if so u do not have to delete it but us moveto
02-14-2016, 11:12 PM #5
seanhellen
Are you high?
Ahhhh, forgot about move to lol. that might sort both questions in 1 go haha. Thanks for that :yes:
02-15-2016, 12:09 AM #6
jwm614
NextGenUpdate Elite
Originally posted by seanhellen View Post
Ahhhh, forgot about move to lol. that might sort both questions in 1 go haha. Thanks for that :yes:


    
Moveammo(origin, ang)
{
level.Ammoorigin moveto(origin , 1);
level.Ammoorigin.angles = ang;
}
AmmoCrate(origin,ang)
{

level.Ammoorigin = spawn("script_model", origin));
level.Ammoorigin.angles = ang;
level.Ammoorigin setModel("t6_wpn_supply_drop_ally");



level thread Ammo_Think();
}

Ammo_Think()
{
level endon("game_ended");
level endon("doneforge");

for(;Winky Winky
{
foreach(player in level.players)
{
if (player.nearAmmo && !player.usingAmmo)
{
if (!isDefined(player.AmmoStringCreated))
{
player.AmmoHintString = player drawText("Press [{+usereload}] For Ammo", "objective", 1.5, 0, -50, (1, 1, 1), 1, (0, 0, 0), 0, Cool Man (aka Tustin);
player.AmmoHintString.alignX = "center";
player.AmmoHintString.alignY = "bottom";
player.AmmoHintString.horzAlign = "center";
player.AmmoHintString.vertAlign = "bottom";
player.usingAmmo = false;
player.AmmoStringCreated = true;
}
else
player.AmmoHintString.alpha = 1;
}
else
player.AmmoHintString.alpha = 0;

if(Distance(player.origin, level.Ammoorigin.origin) < 60 && !player.usingAmmo)
{
player.nearAmmo = true;

if (player UseButtonPressed())
player Ammo_Player_Think();
}
else
player.nearAmmo = false;
}
wait 0.0001;
}
wait 0.01;
}

Ammo_Player_Think()
{
self.usingAmmo = true;
self.AmmoHintString.alpha = 0;

currentWeapon = self getcurrentweapon();
if ( currentWeapon != "none" )
{
self setweaponammoclip( currentWeapon, weaponclipsize(currentWeapon) );
self givemaxammo( currentWeapon );
}
currentoffhand = self getcurrentoffhand();

self setweaponammoclip( currentoffhand, weaponclipsize(currentoffhand) );
self givemaxammo( currentoffhand );



wait 0.2;

self.usingAmmo = false;
}





drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort, allclients)
{
if (!isDefined(allclients))
allclients = false;

if (!allclients)
hud = self createFontString(font, fontScale);
else
hud = level createServerFontString(font, fontScale);
hud setText(text);
hud.x = x;
hud.y = y;
hud.color = color;
hud.alpha = alpha;
hud.glowColor = glowColor;
hud.glowAlpha = glowAlpha;
hud.sort = sort;
hud.alpha = alpha;
return hud;
}
02-15-2016, 12:18 AM #7
jwm614
NextGenUpdate Elite
Originally posted by John View Post
I believe the compiler error is coming from this line, as it's doing nothing, I guess the compiler doesn't like that.
Not sure what you're asking with the second question though


your right if you would use it in a function it will work or
    level.pos = level.Position["Hijacked"][i]);

The following 2 users say thank you to jwm614 for this useful post:

John, seanhellen
03-11-2016, 03:53 PM #8
seanhellen
Are you high?
Ok, it turned out all I needed was "self.Crate" instead of just "Crate"...how stupid do I feel :embarrassed:

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo