Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-24-2010, 04:41 PM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
How do i do?

Hey, im making like a family system for a server and wants to use a DB to store the family info, but how do i load it in to this script? Iknow how to load from servrr. strings, but not from a DB.

Have the following:

PHP Code:
new GuiTextListCtrl("FamilyList")
{
  
profile GuiBlueTextListProfile;
  
0;
  
width 230;
  
fitparentwidth true;
  
clearrows();
  for (
temp.0temp.serverr.familylist.size(); temp.i++)
    
addrow(temp.iserverr.familylist[temp.i]);
    
setSelectedRow(0);

Reply With Quote
  #2  
Old 01-24-2010, 05:25 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
Well you'll need to use triggerserver, and triggerclient to send data back and forth to the client. Then on the server-side you can have a DB NPC called Family (using it for the sake of the example), or so on.

In your Family's DB script you can write some accessors and mutators, here's some very generic ones.

PHP Code:
// Notice that the functions are declared public
// that is so other scripts can call them directly.
public function getValue(dbvar) {
  return 
this.(@dbvar);
}

public function 
setValue(dbvarvalue) {
  
this.(@dbvar) = value;

Then in the server-side portion of your Family's weapon script, you can set and access them using it like so:

PHP Code:
function onCreated() {
  
this.db findnpc("Family");
}

function 
onActionServerSide() {
  if (
params[0] == "exampleSituation") {
    
this.db.setValue("kids"3);
  }
  else if (
params[0] == "getKidsData") {
    
temp.val this.db.getValue("kids");
    
player.triggerclient(this.name"kidsdata"temp.val);
  }
}

//#CLIENTSIDE

function onCreated() {
  
// Due to the nature of this example, I am using two 
  // triggerservers in the same call. NEVER do this in actual code.
  
triggerserver("gui"this.name"exampleSituation");
  
triggerserver("gui"this.name"getKidsData");
}

function 
onActionClientSide() {
  if (
params[0] == "kidsdata") {
    
player.chat "I have " params[1] @ " kids!";
  }

__________________
Quote:
Reply With Quote
  #3  
Old 01-24-2010, 05:44 PM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
Ok, but how can i get them in to the TextList after that?
Reply With Quote
  #4  
Old 01-24-2010, 05:52 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
With the params received on the client-side, you can store them into variables such as this.familys, with that you can then do the following.

PHP Code:
new GuiTextListCtrl("FamilyList"

  
profile GuiBlueTextListProfile
  
0
  
width 230
  
fitparentwidth true
  
clearrows();
  
// You need to use thiso. because you'll need to reference the weapon script
  // and now the FamilyList object itself. 
  
for (temp.0temp.thiso.familys.size(); temp.i++) 
    
addrow(temp.ithiso.familys[temp.i]); 
    
setSelectedRow(0); 

__________________
Quote:
Reply With Quote
  #5  
Old 01-24-2010, 06:28 PM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
Thanks for the help!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:17 AM.


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