Author Topic: Adding Items To Player Inventory?  (Read 1429 times)

Code: [Select]
messageClient(%client,'MsgItemPickup','',0,"GunItem");
For whatever reason, this won't give me a gun.

Full code of unfinished stuffforget
Code: [Select]
package zombiegame
{
function GameConnection::spawnPlayer(%cl)
{
parent::spawnPlayer(%cl); //ffs do this before ANYTHING

if(%cl.infected == nil)
{
%cl.infected = 0;
}
if(%cl.infected == 0)
{
// %cl.joinTeam("Humans");
messageClient(%client,'MsgItemPickup','',0,"GunItem"); //%client,'MsgItemPickup',don't know what goes here,slot number,item
}
if(%cl.infected == 1)
{
// %cl.joinTeam("Zombies");
}
// %cl.centerPrint("Welcome to Brickybob's Quarantine Chaos mod!",3);
%cl.centerPrint(%cl.infected,3);
}
function GameConnection::onDeath(%cl)
{
parent::onDeath(%cl);
%cl.infected = 1;
// %this.spawnPlayer(); - causes beef ghosts; only use under direct ghost butcher supervision
}
};

activatePackage(zombiegame);

Code: [Select]
messageClient(%client,'MsgItemPickup','',0,"GunItem");
let's start with this: i have no idea what the forget you're doing! messageClient sends a chat message, you have the wrong arguments in two spots, and you failed to use it properly. tagged fields are likely above you, so i won't blow your mind.
if(%cl.infected == nil) is this valid?
%this.spawnPlayer(); use %cl, not %this

messageClient(%client,'MsgItemPickup','',0,"GunItem");

%client isn't even defined, use %cl. also, read your code before trying to fix it.
« Last Edit: July 22, 2012, 09:25:03 PM by Lugnut »

Code: [Select]
package zombieGame
{
function GameConnection::spawnPlayer(%cl)
{
parent::spawnPlayer(%cl);

%infected = %cl.infected;

%infected[false] = "HUMANS";
%infected[true] = "ZOMBIES";

if(%cl.infected $= "")
{
%cl.infected = 0;
}

if(%cl.infected == 0)
{
%cl.joinTeam("Humans");

//Search the forums to see if the code below is correct
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
messageClient(%cl,'MsgItemPickup','',0,"GunItem");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
else
if(%cl.infected == 1)
{
%cl.joinTeam("Zombies");
}

%infCentprint = "\c3" @ %infected[%infected] @ "!";

%cl.centerPrint(%infCentPrint,3);
}

function GameConnection::onDeath(%cl)
{
parent::onDeath(%cl);

%cl.infected = true;
}
};
activatePackage(zombieGame);

let's start with this: i have no idea what the forget you're doing! messageClient sends a chat message, you have the wrong arguments in two spots, and you failed to use it properly. tagged fields are likely above you, so i won't blow your mind.
if(%cl.infected == nil) is this valid?
%this.spawnPlayer(); use %cl, not %this

messageClient(%client,'MsgItemPickup','',0,"GunItem");

%client isn't even defined, use %cl. also, read your code before trying to fix it.
I saw it on the addItem event.  That's really my only defense.

There's also multiple lines in the additem event.

So uh,
does anyone really have an answer?

Yeah i'll give you the correct syntaxing for messageclient when i get home.

Use this function to give a player an item:

Code: [Select]
function GameConnection::forceEquip(%this,%slot,%item)
{
%player = %this.player;
if(!isObject(%player))
return;

if(!isObject(%item))
%item = 0;

%oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;

messageClient(%this,'MsgItemPickup','',%slot,%item);

if(!isObject(%oldTool))
%player.weaponCount ++;
}

Yeah i'll give you the correct syntaxing for messageclient when i get home.
elm will deliver
surely we'll wait

elm will deliver
surely we'll wait

Lol, Greek already answered it. When using the name of an item, use this function:

Code: [Select]
nameToId(someItem);