Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   TNT script not working (https://forums.graalonline.com/forums/showthread.php?t=76603)

PrinceOfKenshin 09-01-2007 06:36 PM

TNT script not working
 
Ok so the tnt will only work if you equip it then unequip it and say /tnt
PHP Code:

function onActionServerside()
{
if (
params[1] == "use"){

  if (
clientr.toolcount == NULLclientr.toolcount 0;
  
this.ok 0;

  for (
0clientr.toolcount++) {
    if (
makevar("clientr.tool" i)[1] == "Tools/TNT"this.ok 1;
  }
  if (
this.ok == 0) return;
  if (!
player.level.name.starts("at_mine")) return;
  
serverr.tntlayer player.account;
  
putnpc2(player.xplayer.y"").join("tnt");

  
this.temp = { 1"Tools/TNT""tnt","at_tnt-icon.png"""""1,};
  if (
clientr.toolcount == ""clientr.toolcount 0;
  if (
this.temp[5] == 1) {
    for (
0clientr.toolcount++) {
      if (
makevar("clientr.tool" i)[1] == this.temp[1]) {
        if (
makevar("clientr.tool" i)[4] == this.temp[4]) {
          
makevar("clientr.tool" i)[0] -= 1;
          if (
makevar("clientr.tool" i)[0] <= 0) {
            
makevar("clientr.tool" i) = "";
            for (
i<= clientr.toolcountj++) {
              
makevar("clientr.tool" j) = makevar("clientr.tool" 1);
            }
            
clientr.toolcount--;
          }
        }
      }
    }
  }
}
}

//#CLIENTSIDE
function onCreated() setTimer(.05);

function 
onPlayerChats()
{
  if (
player.chat == "/tnt") {
    if (
this.timer <= 0) {
      
triggeraction(0,0,"serverside",Tools/TNT,"use");
      
this.timer 2;
    } else 
player.chat "You must wait " this.timer "seconds!";
  }
}


function 
onTimeout()
{
  if (
this.timer 0this.timer -=.05;
  else if (
this.timer 0this.timer 0;
  
  
setTimer(.05);



Googi 09-01-2007 09:30 PM

When it doesn't work, does it not execute at all or does it do something like say that the player still has to wait when it shouldn't? From the looks of your script the this.temp[5] in the if statement should be this.temp[6].

Chompy 09-01-2007 09:40 PM

Quote:

Originally Posted by Googi (Post 1345175)
When it doesn't work, does it not execute at all or does it do something like say that the player still has to wait when it shouldn't? From the looks of your script the this.temp[5] in the if statement should be this.temp[6].

Googi is right, change
PHP Code:

if (this.temp[5] == 1) { 

into
PHP Code:

if (this.temp[6] == 1) { 


PrinceOfKenshin 09-05-2007 12:35 AM

It still isn't working. It will work if you equip it then unequip it and reconnect. And even after you log off. I don't know it is confusing to me and this is the only script i need to fix for Atrius to get hosted and no one else on the staff team is helping

Googi 09-05-2007 08:04 AM

Quote:

Originally Posted by PrinceOfKenshin (Post 1345832)
It still isn't working. It will work if you equip it then unequip it and reconnect. And even after you log off. I don't know it is confusing to me and this is the only script i need to fix for Atrius to get hosted and no one else on the staff team is helping

As I said before, tell us what you mean by "not working". Does it execute partially? Does it not execute at all? Which parts don't execute when they should? Debug by having the script produce something visual after each if statement.

DustyPorViva 09-05-2007 09:01 AM

Ya, the best way to fix scripts is to debug the crap out of them. Start by assuming what's the problem, where the script isn't working. Do this by echo'ing variables and other important information. Repeat this process until you figure out what isn't working correctly, what isn't doing what you want it to do, and change it.
Also:
triggeraction(0,0,"serverside",Tools/TNT,"use");
should be:
triggeraction(0,0,"serverside","Tools/TNT","use");
though it's preferred you do:
triggerserver("gui","Tools/TNT","use");

Also, it might be "/tnt", for some reason I have problems getting stuff like player.chat=="/..." to work, but if I remove the /, it works perfectly fine(I doubt this is the problem, but could be... that's what debugging is for). And going along with what everyone else has said, parameters, like array, start their index at 0. so basically subtract 1 from every params[x].


All times are GMT +2. The time now is 05:54 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.