Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #41  
Old 01-24-2014, 01:44 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
There are a few things you could change with what you have written up so far..

We'll start from the beginning, excluding the onSelect event...we'll get back to that, but first:

PHP Code:
//#CLIENTSIDE
/*ignore this...
function Tools.onSelect(temp.i) {
  if (row == 0){
    player.chat = this.items[temp.i][0] SPC "Selected";
  }
}
keep ignoring this..*/

//THIS:
this.tools = {
  {
"Boots"1"no-icon.gif"}, 
  {
"a"2"no-icon.gif"}
}; 
Try not to define arrays or variables outside of a function or an event (if it is not a constant.)
Putting this inside of onCreated() { this.tools = {blah...}; } will work, but I'd recommend an alternative method for defining the tools list (possibly something serverside if this is a shop menu and sending it to the client).

Continuing on...

PHP Code:
function onCreated() {
  new 
GuiWindowCtrl("MyGUI_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "180,218";

    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Tools";
    
1170// <----THIS... 
Alright...so what that's saying is it needs to start at 1170 pixels from the left of the screen, but not every user has a screen/w!ndow that wide

Use
PHP Code:
GraalControl.width this.width
That takes into account the width of their graal/client w!ndow and positions the new menu where you want it...

In your code, your list control is this:
PHP Code:
    new GuiTextListCtrl("Test_List") {
     
profile GuiBlueTextListProfile;
     
0;
     
width 140;
     
fitparentwidth true;
 
     
clearrows();
      for (
temp.ithiso.tools) {
          
addrow(temp.ntemp.i[0]);
          
temp.n++;
        }
     
setSelectedRow(0);
      } 
"Test_List", but in the function you are drawing up or testing, you reference it as "Tools" -- but there is not a control with the name tools...

It should be:

PHP Code:
function Test_List.onSelect(entryid,entrytext,entryindex) {
  
// use entryid, entrytext, or entryindex however you want
  
echo("Clicked " entrytext);

Also, please note, that this ECHO will have to be viewed by pressing F2 and looking at the output there since this is clientside.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #42  
Old 01-24-2014, 07:18 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@Fowlplay Thanks, I couldn't find a thing to use, that's just the kind of thing I was looking for

@Torankusu Thanks for looking through it, it's more of just a random thing I was working on to get more practice with gui's etc, so I didn't think of adding serverside protection or whatever for the array. As for the rest, thanks I'm gonna take a look at my code and see if I can fix these errors
__________________
Reply With Quote
  #43  
Old 01-24-2014, 08:50 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You can find more events for GUI objects here:

http://wiki.graal.net/index.php/Crea...ent/GuiControl
__________________
Quote:
Reply With Quote
  #44  
Old 02-01-2014, 03:03 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I am having trouble with params. I am really not sure how to phrase this question I will try the best I can. Ok so I was making a small shop menu, and I wanted to have the npc trigger the shop menu. In the npc trigger to the shop it would contain the price and other params. I want to be able to use these params in the weapon it triggers and for example make the price.txt = the param price. I also am confused on how the script will know what the trigger is and to make it so it only uses the param of that trigger. For example, if you had more than one triggers going to a weapon script and you wanted to make a gui txt say param 3, how would you be able to tell it to only use param 3 of a certain trigger? I pasted my current script also, as I''m pretty sure I did not phrase any of this right D:
Npc - http://pastebin.com/uiBWRAUL
Weapon - http://pastebin.com/W87eGjhX
__________________
Reply With Quote
  #45  
Old 02-03-2014, 03:51 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Never mind on my last post. I was over thinking something simple.
__________________
Reply With Quote
  #46  
Old 02-03-2014, 05:22 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
For what its worth, params start at 0

Your npc script:
params[0] = buymenu1
params[1] = 1000
params[2] = nameyouhad?

Also, you can do:
onActionClientside (cmd, price, itemname)
and reference the parameters passed from serverside that way.

Ex: echo(price);
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #47  
Old 02-05-2014, 06:22 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Torankusu View Post
For what its worth, params start at 0

Your npc script:
params[0] = buymenu1
params[1] = 1000
params[2] = nameyouhad?

Also, you can do:
onActionClientside (cmd, price, itemname)
and reference the parameters passed from serverside that way.

Ex: echo(price);
Ahh, thanks for the reply anyways .

Would anyone be able to explain tokenizing to me/link me to anything on it please?
__________________
Reply With Quote
  #48  
Old 02-05-2014, 11:45 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Ahh, thanks for the reply anyways .

Would anyone be able to explain tokenizing to me/link me to anything on it please?
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #49  
Old 02-05-2014, 10:47 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Torankusu View Post
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
ps: if its only for spaces, you could also just do player.chat.tokenize()
__________________
MEEP!
Reply With Quote
  #50  
Old 02-05-2014, 11:51 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Torankusu View Post
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
Thanks , would you use tokenizeing as well when doing such scripts as
PHP Code:
if (player.chat.starts("text")){ 
player.chat.substring;

?
Also, for the delimiters, you would basically be able to put for example a word such as "idigzy" and wherever that word occurs it splits it :o?
__________________
Reply With Quote
  #51  
Old 02-06-2014, 12:31 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Thanks , would you use tokenizeing as well when doing such scripts as
PHP Code:
if (player.chat.starts("text")){ 
player.chat.substring;

Your example isn't a proper use of substring ( string.substring(index[,length]) ) , but, essentially, yes, you could tokenize the player's chat if a condition is met. I'll let someone else fill you in on substring as I know how it works (sometimes), but am not familiar enough to verse you on its uses...sorry...


random tailor example for tokenize [better ways to do this...example for simplicity sake..]:
PHP Code:
if (player.chat.starts("/set ")){ //player says "/set shoes"
  
player.chat.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
    
//OR...
    //player.colors[2] = player.chat.substring(10,-1); // not 100% sure on this??
  
}

Quote:
Also, for the delimiters, you would basically be able to put for example a word such as "idigzy" and wherever that word occurs it splits it :o?
yeah, you get the concept....
some common delimiters: are , (commas), spaces . (periods) , and so on...

there is a tokenize2 but I didn't want to include it.
You can scripthelp it.

Is there anything you are trying to do in specific, there might be a better approach?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #52  
Old 02-06-2014, 01:37 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@Torankusu Thanks for all the help on that . I'm not really trying to do anything in particular at the moment, I just thought I'd play around with it since I may use it in the future.
__________________
Reply With Quote
  #53  
Old 02-06-2014, 03:16 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
PHP Code:
str.substring(start[,length]) - extracts a substring out of str 
the second parameter is how long you want to grab for the substring. -1 for the length will go to the end of the string.

Also
PHP Code:
function ChatBar.onAction() 
is the same as
PHP Code:
function onPlayerChats() 
From what I understand it's recommended to use ChatBar. I've even had issues with playerchats here and there, but not with chatbar. ChatBar is the Gui default where you type in the text.

and
PHP Code:
ChatBar.text 
is the same as
PHP Code:
player.chat 
when using the ChatBar function instead.

so:
PHP Code:
function ChatBar.onAction() {
  if (
ChatBar.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #54  
Old 02-07-2014, 07:23 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@sssssssssss thanks for the response
__________________
Reply With Quote
  #55  
Old 02-08-2014, 12:34 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I saw an error in my code. :x sry

PHP Code:
function ChatBar.onAction() {
  if (
ChatBar.text.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #56  
Old 02-09-2014, 04:12 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Would anyone be able to link me to some guides on databases/some good examples ?
__________________
Reply With Quote
  #57  
Old 02-09-2014, 06:48 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by iDigzy View Post
Would anyone be able to link me to some guides on databases/some good examples ?
The Graal wiki has a good page on the use of SQLite in GScript.

http://wiki.graal.net/index.php/Crea...t/Using_SQLite
Reply With Quote
  #58  
Old 02-09-2014, 09:28 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by cyan3 View Post
The Graal wiki has a good page on the use of SQLite in GScript.

http://wiki.graal.net/index.php/Crea...t/Using_SQLite
I wouldn't really call it a good page. A lot of the explanation is not very clear and I didn't have a very good understanding of SQLite when I wrote it.

My advice would probably be to learn SQL/SQLite outside of Graal first. Using it in Graal will then be pretty easy.
__________________
Reply With Quote
  #59  
Old 02-10-2014, 10:11 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by sssssssssss View Post
I saw an error in my code. :x sry

PHP Code:
function ChatBar.onAction() {
  if (
ChatBar.text.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
now if there isnt some kind of error then ill restart scripting and learn it all from the beginning
__________________
MEEP!
Reply With Quote
  #60  
Old 02-11-2014, 01:49 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
:x
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #61  
Old 02-11-2014, 11:10 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@ cyan3 thanks for the link, but I should have made myself more clear, I'm trying to practice/learn database npc more at the moment, I will be learning or starting SQL whenever I am more advanced
@cbk1994 I'll remember that for when I start thanks

I'm really stuck on database/database npc's though. Are there many guides/information on them? Also, how would you go about making for example a simple spar stat database to keep information on player spar wins? Also, could someone possibly explain why/when you would use them more often, as it would probably make more seance to just use clientr to record spar stats for example?
__________________
Reply With Quote
  #62  
Old 02-11-2014, 11:42 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
I can't help much with this, but I can give you an example in relation to the shop stuff you were working on previously.

full script: http://forums.graalonline.com/forums...highlight=shop

In a Database NPC, such as: DB_Prices, put the following:
PHP Code:
function onCreated() 

  
// Format: 
  // this.item_id = price 
   
  
this.item_100 3// 3 gralats in this case 
  
this.item_200 5// 5 gralats in this case, etc...

You can access it in other scripts such as this:

PHP Code:
  this.price DB_Prices.("item_" this.item); //could also be temp.price if you just wanted to store it temporarily 
It adds a bit more security behind transactions as the prices between certain items (ex: this.item_100) cannot be manipulated when purchasing an item in a client menu, as it gathers the price data on the serverside from the Database (DB_Prices).

That is just one example. I do hope someone else can chime in because I would like to learn a bit more when a Database NPC might be more plausible than just a regular level NPC, etc...
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #63  
Old 02-13-2014, 06:07 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Thanks for the reply, but I'm still having trouble with them. I tried to make a simple npc where when the player touchs it, it will chat the databases flag. In the database I have
PHP Code:
function onCreated()
{

  
this.item_100 "test";

inside the npc on serverside is
PHP Code:
function onPlayerTouchsMe() {
  
this.chat DB_test.("item_100" this.item);

this ends up not setting the chat to test and ends up making it 0, so I assume I identified the flag wrong?
__________________
Reply With Quote
  #64  
Old 02-13-2014, 06:37 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Thanks for the reply, but I'm still having trouble with them. I tried to make a simple npc where when the player touchs it, it will chat the databases flag. In the database I have
PHP Code:
function onCreated()
{

  
this.item_100 "test";

inside the npc on serverside is
PHP Code:
function onPlayerTouchsMe() {
  
this.chat DB_test.("item_100" this.item);

this ends up not setting the chat to test and ends up making it 0, so I assume I identified the flag wrong?

Right. What is the name of your database? Your script says its DB_test

Also, you need to indicate the item id in the npc you're touching somewhere: ex:
this.item = 100;

Then reference it like this:
this.chat = DB_test.("item_" @ this.item);
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #65  
Old 02-13-2014, 06:48 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Maybe this is what you're looking for.

DB_test:
PHP Code:
function onCreated() {
  
this.item_100 "test";
}

public function 
findItem(temp.id) {
  return 
this.(@ "item_" temp.id);

Script:
PHP Code:
function onCreated() {
  
this.id 100;
}

function 
onPlayerTouchsMe() { 
  
player.chat DB_test.findItem(this.id);

__________________
Reply With Quote
  #66  
Old 02-15-2014, 05:14 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Tim_Rocks View Post
Maybe this is what you're looking for.

DB_test:
PHP Code:
function onCreated() {
  
this.item_100 "test";
}

public function 
findItem(temp.id) {
  return 
this.(@ "item_" temp.id);

Script:
PHP Code:
function onCreated() {
  
this.id 100;
}

function 
onPlayerTouchsMe() { 
  
player.chat DB_test.findItem(this.id);

Thanks for the reply, but I still can't get anything to work. Does it matter what level the npc database is in? It keeps making the chat 0, I have tried altering it a bit still can't figure it out .
__________________
Reply With Quote
  #67  
Old 02-15-2014, 06:08 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Thanks for the reply, but I still can't get anything to work. Does it matter what level the npc database is in? It keeps making the chat 0, I have tried altering it a bit still can't figure it out .
i understand you are trying to learn how to use DBNPCs properly, but it would help us troubleshoot if you gave us an idea on exactly what you are trying to do.

I understand you might be trying to go off of my previous examples, but could you give us some code examples ?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #68  
Old 02-15-2014, 05:26 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
This may be really off, but I tried to make it so when a player touches the npc it adds 1 to the item_playersname in the databse. Can someone explain what is wrong here and how to fix please?

In NPC:
PHP Code:
function onPlayerTouchsMe() {
  
this.playername player.account;
  
this.ida stats_(this.playername);
  
DB_test.addstats(this.ida) += 1;

In Database:
PHP Code:
function onCreated() {
  
this.item_Graal1059025 =1;
}

public function 
addstats(this.ida) {
  return 
this.(@ "item_" this.ida) += 1;

__________________
Reply With Quote
  #69  
Old 02-16-2014, 05:06 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Yeah, seems like you didn't format things properly..

wrong: this.ida = stats_(this.playername);
right: this.ida = (@ "stats_" @ this.playername);

wrong: DB_test.addstats(this.ida) += 1;
right: DB_test.addstats(this.ida);

Although the way you set this up was odd, here's how I would of done it.

NPC:
PHP Code:
function onPlayerTouchsMe() {
  
temp.amt DB_test.addstats(); //You could specify another amount in the parentheses. 

  
player.chat "I've touched this NPC " temp.amt " time(s).";

DB_test:
PHP Code:
function onCreated() { 
  
//this.stats_Graal1059025 =1; 
  //You really don't need the line above unless you want the stats being reset.
}

public function 
addstats(temp.amt) {
  if (
temp.amt null) {
    return 
null//We don't want negatives.
  
}

  if (
temp.amt == null) {
    
temp.amt 1;
  }
  
  return 
temp.stats this.(@ "stats_" player.account) += temp.amt;

I did notice you were mixing "stats" and "item" together. Hopefully this example works, I didn't have a chance to test it.
__________________
Reply With Quote
  #70  
Old 02-18-2014, 03:51 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Thanks tim and torankusu for the help. I finally get how to set it up
__________________
Reply With Quote
  #71  
Old 02-23-2014, 03:58 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I started to take a look at sql and I am pretty stuck on some basic things . I wanted to try to make a simple login database for practice, but I couldn't get it to work at all. I used the SQL explorer and put in :

PHP Code:
CREATE TABLE 'login list' 
player TEXT
 

This worked great until I wanted to add information to it from an npc. Is it possible to do the following/if so what would I be doing wrong?

The script in the npc is - http://pastebin.com/2s1HeB2L

(The forums were giving me an error so I just pasted the scripts on pastebin instead)
__________________
Reply With Quote
  #72  
Old 02-23-2014, 05:55 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
I think you should stick to the other scripting stuff before jumping over to sql
__________________
MEEP!
Reply With Quote
  #73  
Old 02-23-2014, 06:53 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: 360
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
callimuc is correct, it is not a good idea to delve into sql while not being completely familiar with the language syntax

there are at least 4 problems with what you are attempting to do -
  • for creating the table, the table name does not need to be within quotes and there is no primary key (index) which is a really good idea to include, it is also not a good idea to use spaces within table or column names, a correct example would be - CREATE TABLE loginList (pID INTEGER PRIMARY KEY, account VARCHAR NOT NULL)
  • the players account isnt being concatenated into the insert query string correctly, in gs2 this is what '@' is for, for example - temp.string = "test_" @ player.account @ "_test2";
  • you have player.account wrapped within " " quotes when it is a variable, which if the concatenation was correct it would literally use the text 'player.account' as opposed to the actual account of the player object
  • the table column name is not being set within ( ) brackets

if you ever encounter sql within a live environment you should never tamper with it unless you are completely sure about how it works and how to use it
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #74  
Old 02-23-2014, 11:54 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Thanks for the replies, I guess I'll just stick with learning some other things for now than
__________________
Reply With Quote
  #75  
Old 03-22-2014, 12:55 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
I am working on making a custom chat system, and I wanted to have a gui to display previous chat from the player and other players. I managed to get most of it to work, but I am stuck on getting it to send to other players gui and have it display others text. Can someone explain what is wrong and possibly if there is a better way to find the players than by if they are in the same level?

trigger:
PHP Code:
function onPlayerChats() {
 
triggerserver("gui"this.name"sendchat"player.accountplayer.chatplayer.account);

serverside:
PHP Code:
function onActionServerSide() {
  if (
params[0] == "sendchat") {
    for (
pl allplayers) {
      if (
pl.level == findplayer(params[3]).level) {
        
triggerclient("gui"this.name"displaychat"params[1], params[2]);
       }
    }
  }

the clientside that is retrieved if play is in same area:
http://pastebin.com/ts8SGipV (forum kept giving me a denial message, so I posted it there)


entire script if it helps to get an idea of what i'm doing:
http://pastebin.com/Fm0CMqGb
__________________
Reply With Quote
  #76  
Old 03-22-2014, 02:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You probably want to do pl.triggerClient so you're triggering on that player, not on whoever the current player happens to be.
__________________
Reply With Quote
  #77  
Old 03-22-2014, 03:47 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
You probably want to do pl.triggerClient so you're triggering on that player, not on whoever the current player happens to be.
ahh that didn't occur to me, thanks I got it to work now
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:07 PM.


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