View Single Post
  #11  
Old 11-21-2013, 09:39 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 358
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
Quote:
Originally Posted by iDigzy View Post
Thanks, I knew about fowlplay's but I'll check out the gscript dev one

I have another question, (I think it would be better just to post any questions I have under this thread instead of spamming forums, not sure). I am trying to make a staff block/spawn and npc. I somewhat know how to make it, but I'm not sure how you would do it. This is my current script so far.
NPC Code:
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat = ":blockspawnon") {
enabled = true;
if (player.chat = ":blockspawnoff") {
enabled = false;
}
if (enabled = true) {
player.chat = "Block Spawned!";
putnpc("block.png","test",30,30);
this.chat = "block";
drawunderplayer();
block();
}
}
}

when comparing values you need to use '==' rather than '=', as '=' is for assigning values and when assigning values it always returns true

for this example you should be assigning the variable using the 'this.' prefix, otherwise it would apply globally which would cause conflict if there were multiple copies of this npc

its also good to avoid checking conditions you already know to be false, for example you can do -

PHP Code:
if (player.chat == ":blockspawnon") {
  
this.enabled true;
}
else if(
player.chat == ":blockspawnoff") {
 
this.enabled false;

or -

PHP Code:
  this.enabled = (player.chat == ":blockspawnon") ? true :
    (
player.chat == ":blockspawnoff") ? false this.enabled
  

__________________
This signature has been deleted by Darlene159.
Reply With Quote