Author Topic: Adding + removing weapon  (Read 826 times)

Ohai coding help place.

So i want to make a trigger that adds a weapon (sniper) when you enter and removes it when you leave, Can i do this and if so how :D

i did have a look at this but i didn't understand :3

That would be quite useful :D

yeah :D

i wana make a hill side for sniping

Because using sniper all the time completely ruins the fun. and removes all strategy

Try when you enter the trigger, mount a sniper, and when you leave, unmount slot 0.

Try when you enter the trigger, mount a sniper, and when you leave, unmount slot 0.
Code: [Select]
datablock TriggerData(GiveSniperTrigger)
{
    tickPeriodMS = 100;
}

function GiveSniperTrigger::onEnterTrigger(%this,%trigger,%obj)
{
    %obj.mountImage(sniperImage,0);
}

function GiveSniperTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
    %obj.unmountImage(0);
}
Untested

something similar could be have a sniper hidden inside a block, and have a touch trigger make the block disappear, and then when you leave the block will get back...(wrench eventts)

door--> invinsible invisable (desc:123)
triggers--> touch (activate:123)
door--> (no boxes checked) (desc: 123(same block)
triggers-->touch(activate 123)

I don't use events. Ever. Events can rot in hell.

Try when you enter the trigger, mount a sniper, and when you leave, unmount slot 0.
Code: [Select]
datablock TriggerData(GiveSniperTrigger)
{
    tickPeriodMS = 100;
}

function GiveSniperTrigger::onEnterTrigger(%this,%trigger,%obj)
{
    %obj.mountImage(sniperImage,0);
}

function GiveSniperTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
    %obj.unmountImage(0);
}
Untested
No works :3 You did alot of things wrong anyway :D its trig not trigger
« Last Edit: July 30, 2008, 03:58:44 AM by tails »

Quote
its trig not trigger
It doesn't matter, it's a variable name, it can be anything. If I want to call it %IdentificationNumberOfTheTriggerEntered then I can, and it will still work. Same with using %client, %this or anything in a GameConnection:: function.

Code: [Select]
datablock TriggerData(SniperTrigger)
{
    tickPeriodMS = 100;
}

function SniperTrigger::onEnterTrigger(%this,%trigger,%obj)
{
if(%obj.getClassName() !$= "Player" && %obj.getClassName() !$= "AIPlayer")
return;
if(!%obj.canPickup)
return;
for(%i=0;%i<5;%i++)
{
%tool = %obj.tool[%i];
if(%tool == 0)
{
%obj.tool[%i] = SniperRifleItem.getID();
%obj.weaponCount++;
messageClient(%obj.client,'MsgItemPickup','',%i,SniperRifleItem);
break;
}
}
}

function SniperTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
if(%obj.getClassName() !$= "Player" && %obj.getClassName() !$= "AIPlayer")
return;
for(%i=0;%i<5;%i++)
{
%tool = %obj.tool[%i];
if(%tool == SniperRifleItem.getID())
{
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
}
}
}

function SniperTrigger::onTickTrigger(%this,%trigger)
{
}

package dropping
{
 function servercmdDropTool(%client)
 {
  if(%client.player.tool[%client.currTool] == SniperRifleItem.getID()){return;}
  Parent::servercmdDropTool(%client);
 }
};activatepackage(dropping);
This should give players a sniper rifle in their inventory if they have a free slot as they enter the trigger (place in F11) and remove it when they leave but can use other weapons while in there as well. Players cannot drop the rifle to "cheat" and gain one outside the trigger. Give the Sniper Rifle no uiName or don't let people spawn them to make it work better.

It doesn't matter, it's a variable name, it can be anything. If I want to call it
k

Thanks mr space guys :D

Now i can maek lovey deathmatch with less cheating :3

Almost reminded me of Kunit saying that %obj is part of the engine code and you dont have to define it at all.
Well, he did say someone told him that.