Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-14-2013, 11:46 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
If you're going to use SQL, you should leverage it else where.

Are you going to have a character slot system? If so you should establish a 'characters' table. I.e.

Characters

ID
Account

Then your other tables you should use the Character ID as the reference. I.e. For Quests:

Quests

ID - Autoincrementing integer
ScriptID - String - quest_id
Name
Description

QuestProgress

ID - Autoincrementing integer
Quest ID - Integer - Quest's ID
Character ID - Integer - Character's ID
Completed (Boolean)

Using this structure you can perform queries like...

PHP Code:
// Returns all quests player is currently on and has completed
public function getQuestData(pl) {
  
temp.statement format("SELECT Quests.name AS quest_name, Quests.description AS quest_description, QuestProgress.completed AS quest_completed
                             FROM Quests, QuestProgress
                            WHERE Quests.ID = QuestProgress.QuestID
                              AND QuestProgress.CharacterID = %s"
formatstring2(pl.clientr.characterid));
                              
  
temp.response requestsql(temp.statementtrue);
  if (
temp.response.rows.size() > 0) {
    
temp.data = {};
    for (
temp.rowtemp.response.rows) {
      
temp.data.add({
        
temp.row.quest_name,
        
temp.row.quest_description,
        
temp.row.quest_completed
      
});
    }
    return 
temp.data;
  } else {
    return 
"";
  }
}

public function 
getQuestsCompleted(pl) {
  
temp.statement format("SELECT COUNT(Quests.ID) AS quests_completed FROM QuestProgress WHERE QuestProgress.CharacterID = %s AND quest_completed = 1"formatstring2(pl.clientr.characterid));
  
temp.response requestsql(temp.statementtrue);
  return (
temp.response.rows[0].quests_completed);

__________________
Quote:

Last edited by fowlplay4; 12-14-2013 at 11:58 PM..
Reply With Quote
 


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:03 AM.


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