Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Icon Script (https://forums.graalonline.com/forums/showthread.php?t=87514)

Damien 08-20-2009 08:36 PM

Icon Script
 
I suck at scripting, this is what i got. can i have some help?


PHP Code:

//CLIENTSIDE
function onCreated()
{
 
this.stafflist = {
                      
"Manager"
                      "Staff"
                      "Etc"
                      
}
  if (
player.guild this.stafflist)
  {
   
showimg ("stafficon.png"player.x-0.04player.y-3.3)
  )



Switch 08-20-2009 09:15 PM

Quote:

Originally Posted by Damien (Post 1516744)
I suck at scripting, this is what i got. can i have some help?


PHP Code:

//CLIENTSIDE
function onCreated()
{
 
this.stafflist = {
                      
"Manager"
                      "Staff"
                      "Etc"
                      
}
  if (
player.guild this.stafflist)
  {
   
showimg ("stafficon.png"player.x-0.04player.y-3.3)
  )



You need to use //#CLIENTSIDE and not //CLIENTSIDE for starting the clientside portion.

You need a semicolon (; ) after using any commands or setting something. That means that this doesn't apply to a function, check, loop, etc.
Example
PHP Code:

player.chat "I just set the player's chat."

Arrays need a comma (,) in-between strings and variables.
Example
PHP Code:

temp.array = { "string 1","string 2",26,}; 

A check requires (or should :\) == instead of =, which is for setting something.
Example
PHP Code:

this.check "pie";
if (
this.check == "pie") {
  
//code


Since you are checking if the player's guild is in an array and not a specific string, you need to use in instead of == for the check.
Example
PHP Code:

temp.array = { 1,};
if (
this.action in temp.array) {
  
//code


showImg() has 4 params:
integer (for ID), string (the image's file name), float (x coordinate), float (y coordinate)
Example
PHP Code:

showImg(200,"block.png",player.x,player.y); 

And I'm sure your last mistake was a typo, which is that you accidentally closed a check with ) instead of }.

Here is the correct code (I use my own styling, you don't necessarily have to follow it):
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
temp.staffList = { "Manager","Staff","Etc" };
  if (
player.guild in temp.staffList)
    
showImg(200,"stafficon.png"player.x-0.04player.y-3.3);


I used a temp array instead of a this array since it is only called inside that one function (onCreated()).

Anyways, you should make a Gani script set as a player.attr[] for this.

Pelikano 08-20-2009 09:21 PM

Quote:

Originally Posted by Switch (Post 1516770)
Here is the correct code (I use my own styling, you don't necessarily have to follow it):
PHP Code:

//CLIENTSIDE
function onCreated() {
  
temp.staffList = { "Manager","Staff","Etc" };
  if (
player.guild in temp.staffList)
    
showImg(200,"stafficon.png"player.x-0.04player.y-3.3);


I used a temp array instead of a this array since it is only called once.

Anyways, you should make a Gani script with an attr[] for this.

To clarify, since it's not used outside the function, not because it's called once...

Switch 08-20-2009 09:25 PM

Quote:

Originally Posted by Pelikano (Post 1516775)
To clarify, since it's not used outside the function, not because it's called once...

Too tired :(

Anyways I forgot to mention this in my original post, but you should try to fix these things on your own. RC should have displayed some error messages to lead you in the right path.

Inverness 08-20-2009 09:58 PM

It's //#CLIENTSIDE not //CLIENTSIDE.

Switch 08-20-2009 10:07 PM

Quote:

Originally Posted by Inverness (Post 1516805)
It's //#CLIENTSIDE not //CLIENTSIDE.

Quote:

Originally Posted by Switch (Post 1516780)
Too tired :(

need text

Damien 08-20-2009 10:07 PM

Jeez, I am VERY bad at this. I left out semicolons for god sake..


All times are GMT +2. The time now is 04:48 PM.

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