Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-24-2011, 04:21 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
SQlite and Observer Mode

On Classic I have it so that account data is added to an SQLite database on a player's first login, and if they have already logged in it is then updating the existing data.

For example:

PHP Code:
//Called within onActionPlayerOnline from Control-NPC
public function playerLoggedIn(temp.pl){
  if(
temp.pl.communityname == NULL){
    
temp.cn temp.pl.account;
  }
  else{
    
temp.cn temp.pl.communityname;
  }
  
//The player does not have a flag for being added to the database
  
if(!temp.pl.stat_sqlsetup){
    
temp.query "INSERT INTO tPlayer (account, subscription, lastlogin, gelats, communityname) VALUES ('" temp.pl.account "', '" temp.pl.getSubcription() @ "', " temp.pl.getLoginTime() @ ", " temp.pl.getGelat() @ ", '" temp.cn "')";
    
this.trigger("SQLCommit"temp.query"PlayerStored"temp.pl);
  }
  else{
    
//The player does have a flag for being added to the database
    
temp.query "UPDATE tPlayer SET subscription = '" temp.pl.getSubcription() @ "', lastlogin = " temp.pl.getLoginTime() @ ", gelats = " temp.pl.getGelat() @ ", communityname = '" temp.cn "' WHERE account = '" temp.pl.account "'";
    
this.trigger("SQLCommit"temp.query);
  }

The class script containing "SQLCommit" is as follows:

PHP Code:
function onSQLCommit(temp.querytemp.triggernametemp.param1temp.param2temp.param3){
  
temp.request requestsql(temp.querytrue);
  if(!
temp.request.completed){
    
waitfor(temp.request"onReceiveData"5);
  }
  
//If something goes wrong, such as a failed constraint, the query is logged and no function is triggered
  
if(temp.request.error != NULL){
    
savelog2("log_sql.txt"temp.request.error " : " temp.query);
    echo(
temp.request.error);
    return;
  }
  if(
temp.triggername != NULL){
    
this.trigger(temp.triggernametemp.requesttemp.param1temp.param2temp.param3);
  } 

So in this case, assuming all goes well, this function would be triggered:

PHP Code:
function onPlayerStored(temp.rtemp.pl){
  
temp.pl.stat_sqlsetup true;

The problem I am having is that a small portion of trial accounts are producing an error of "constraint failed", sometimes the problem is that they are added to the database but somehow the flag has not set. Other times the flag is set but they have not been added to the database, and so it fails whenever they are added to a different table containing their primary key of the first table.

As far as I can tell this seems to co-inside with Observer Mode.
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 03:59 PM.


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