Quote:
Originally Posted by Sum41Freeeeek
I'm making a gang system, but I'm having a small problem.
I have this in a class:
PHP Code:
function onPlayerchats()
{
if (player.chat.starts(":"))
{
findNpc("Gang Control").leaderCommand(player.chat);
}
}
and I have this in the Gang Control npc
PHP Code:
public function leaderCommand(toks)
{
switch (temp.toks[0])
{
case ":addmember":
player.chat = "testing";
break;
}
}
when I say :addmember alone, it switches my test to "testing" which is what I want, sort of (since I'm trying to debug it) but if I say :addmember blahwhatever, it doesn't do anything.
even if I changed it to player.chat = temp.toks[1]; , it doesn't return temp.toks[1] what am I doing wrong?
sorry if I don't explain it that well, I tried my best.
|
When I use switch( var ), I find it helpful to do it like this:
PHP Code:
switch ( var )
{
case "test":
{
// Stuff Here
break;
}
case "blah":
{
// More stuff here.
break;
}
}
The braces organize it better, I think atleast.