[HowTo] Using dudb 2.4 to save money/stats/whatever (0.2#Ready)
#21

When I Compilated "dutils.dtest" I saw this:

E:\GRANDT~1\SAMP01~1\FILTER~1\DUTILS~1.PWN(2) : fatal error 100: cannot read from file: "dtest"

Compilation aborted.Pawn compiler 3.0.3367 Copyright © 1997-2005, ITB CompuPhase


1 Error.

What should I do?
Reply
#22

download http://forum.sa-mp.com/index.php?topic=480.0 dtest first ... ^^
Reply
#23

why logged in player is reconnect to server, that don't give money or score to player?

and when he typed "/login password", that saying "already authed"

Reply
#24

When does this happen?

did you added this?
pawn Code:
public OnPlayerConnect(playerid) {
 PLAYERLIST_authed[playerid]=false;
 return false;
}
Reply
#25

Quote:
Originally Posted by DracoBlue
When does this happen?

did you added this?
pawn Code:
public OnPlayerConnect(playerid) {
 PLAYERLIST_authed[playerid]=false;
 return false;
}
me this not working (OnPlayerConnect function not started, when i have first filterscript admingivecash, i delete filterscript, and all is ok)
Reply
#26

Quote:
Originally Posted by DracoBlue
When does this happen?

did you added this?
pawn Code:
public OnPlayerConnect(playerid) {
 PLAYERLIST_authed[playerid]=false;
 return false;
}
of course, i add that.
Reply
#27

tried smrtalks advice?
Reply
#28

oh, i fixed it.

i add that functions in the my mod file, not filterscripts.
Reply
#29

Quote:
Originally Posted by DracoBlue
tried smrtalks advice?
all is ok, but when is first filterscript in config file "admingivecash", this function (OnPlayerConnect) not work, i dont know why, i more no-examine it...
Reply
#30

This is a great script! I was wondering how easy it would be to save the cash in the bank with this script? My users would have to get all their cash out the bank and then quit for them to save money. Can someone point me in the right direction?

Thanks.
Reply
#31

Код:
#include <a_samp>
// for the samp stuff
#include <dutils>
// for the functions dini and dudb need
#include <dudb>
// for the userdatabase, get dudb version 1.2 for this.
#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1
#define COLOR_SYSTEM 0xEFEFF7AA



new PLAYERLIST_authed[MAX_PLAYERS];

public SystemMsg(playerid,msg[]) {
  if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
    SendClientMessage(playerid,COLOR_SYSTEM,msg);
  }
  return 1;
}

 public OnPlayerCommandText(playerid,cmdtext[]) {
 dcmd(login,5,cmdtext) // because login has 5 characters
 dcmd(register,8,cmdtext) // because register has 8 characters
 return false;
}

public OnPlayerConnect(playerid) {
 return false;
}

/*
 * This function will be useful when we need the playername
 * © by DracoBlue 2006
 */
public PlayerName(playerid) {
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
 return name;
}





/*
 * /register password
 *
 */
 dcmd_register(playerid,params[]) {

  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");

  // The command shouldn't work if an account with this
  // nick already exists
  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'.");

  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'");

  // We save the money to the accstate
  if (udb_Create(PlayerName(playerid),params,GetPlayerMoney(playerid),"")) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now.");
  return true;

 }
 
 
 
 
 /*
 * /login password
 *
 */
 dcmd_login(playerid,params[]) {

  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");

  // The command shouldn't work if an account with this
  // nick does not exists
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");

  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");

  if (udb_CheckLogin(PlayerName(playerid),params)) {
    // Login was correct

    // Since we are using the "accstate"-variable to save and
    // read the money of the player, we can update his money now.

    // Following thing is the same like the missing SetPlayerCommand
    GivePlayerMoney(playerid,udb_getAccState(PlayerName(playerid))-GetPlayerMoney(playerid));

    PLAYERLIST_authed[playerid]=true;

    return SystemMsg(playerid,"Successfully authed!");
  } else {
    // Login was incorrect
    return SystemMsg(playerid,"Login failed!");
  }
  return true;
 }
 
 
 

public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
   // Was loggedin, so save the data!
   udb_setAccState(PlayerName(playerid),GetPlayerMoney(playerid));
 }
 return false;
}

Can Anyone Tell me What I Did Wrong....? plz
Reply
#32

Should each username file have a unique id? If so mine seems to be creating them all username.1 heres code:
http://pastebin.ca/137523

Im using it with LVDM mod.
Reply
#33

You got the same errors as me:
GTA San Andreas\samp\gamemodes\src\Game.pwn(23) : error 001: expected token: ";", but found "if"
GTA San Andreas\samp\gamemodes\src\Game.pwn(24) : error 001: expected token: ";", but found "return

I looked at line 23 and 24... but i cant find whats wrong....

Reply
#34

you need to close the lines off with: ;

where the commands happen.
Reply
#35

Thanks, that works now, But...

When samp-server tries to load DUDBdtest filterscript... it closes

This is the log:

Код:
 SA:MP Dedicated Server
 ----------------------
 v0.1, ©2005-2006 SA:MP Team

Executing Server Config...
C:\Program Files\Rockstar Games\GTA San Andreas\samp\scriptfiles\

 Filter Scripts
 ---------------
 Loading filter script 'DUDB.amx'...
 Loading filter script 'DNick.amx'...
 Loading filter script 'register3.amx'...
 Loading filter script 'mytest.amx'...

 _____________________________________________________________________________
 :                                 \ DTEST |
 '                                  `------ґ
  Testing: left() and right() by Y_Less
  (17:58:54, 18. Aug 2006)

   <left>
   [OK] left("Hello World",4) Hell == Hell
   [OK] left("Hello World",4) Hell == Hell
   [OK] tmp Hello World == Hello World
   [OK] left("",5) == 
   [OK] left("Hello",0) == 
   [OK] left("Hello",0) <> Hello
   [OK] left("Hello",-5) == 
   [OK] left("Hello",-5) <> Hello
   [OK] left("Hello",MAX_STRING+2) Hello == Hello
   
   <right>
   [OK] right("Hello World",4) orld == orld
   [OK] right("Hello World",4) orld == orld
   [OK] tmp Hello World == Hello World
   [OK] right("",5) == 
   [OK] right("Hello",0) == 
   [OK] right("Hello",0) <> Hello
   [OK] right("Hello",-5) == 
   [OK] right("Hello",MAX_STRING+2) Hello == Hello
   
                                    
 __                                    .
 |__\________________________________________________________________________:

                                    
 __                                    .
 |__\________________________________________________________________________:

 Loading filter script 'dutilsdtest.amx'...

 _____________________________________________________________________________
 :                                 \ DTEST |
 '                                  `------ґ
  Testing: DUtils
  (17:58:54, 18. Aug 2006)

   <StripNewLine>
   [OK] "Huhu"<>"Huhu"+13+10 Huhu

 <> Huhu
   [OK] StripNewLine("Huhu"+13+10) Huhu == Huhu
   [OK] StripNewLine("Huhu") Huhu == Huhu
   [OK] StripNewLine("Huhu"+10) Huhu == Huhu
   [OK] StripNewLine(13+10) == 
   [OK] StripNewLine(10) == 
   [OK] StripNewLine() == 
   
   <ret_memcpy>
   [OK] ret_memcpy("Huhu",0,2) Hu == Hu
   [OK] ret_memcpy("Huhu",0,4) Huhu == Huhu
   [OK] ret_memcpy("Huhu",0,10) Huhu == Huhu
   [OK] ret_memcpy("Huhu",5,5) == 
   [OK] ret_memcpy("Huhu",1,1) u == u
   [OK] ret_memcpy("Huhu",0,1) H == H
   [OK] ret_memcpy("Huhu",1,2) uh == uh
   [OK] ret_memcpy("Huhu",3,1) u == u
   [OK] ret_memcpy("Huhu",3,3) u == u
   [OK] ret_memcpy("Huhu",4,1) == 
   
   <copy>
   [OK] copy(dest,"Hallo",4) Hall == Hall
   [OK] copy(dest,"Hallo",0) == 
   [OK] copy(dest,"Hallo",120) Hallo == Hallo
   [OK] copy(dest,"Hallo",-1) == 
   
   <del>
   [OK] del(dest,-2) Hello == Hello
   [OK] del(dest,1) ello == ello
   [OK] del(dest,2) lo == lo
   [OK] del(dest,0) lo == lo
   [OK] del(dest,10) == 
   [OK] del(dest,2) == 
   
   <copyEx>
   [OK] copyEx(dest,"Hallo",4,1) allo == allo
   [OK] copyEx(dest,"Hallo",0,1) == 
   [OK] copyEx(dest,"Hallo",120,1) allo == allo
   [OK] copyEx(dest,"Hallo",-1,1) == 
   
   <set>
   [OK] set(dest,"Hallo") Hallo == Hallo
   [OK] set(dest,"H") H == H
   [OK] set(dest,"") == 
   [OK] set(dest,"") H == H
   
   <equal>
   [OK] equal("Hallo","hallo",true) true == true
   [OK] equal("Hallo","Hallo",true) true == true
   [OK] equal("Hall","hallo",true) false == false
   [OK] equal("Hall","hallo",false) false == false
   [OK] equal("","hallo",false) false == false
   [OK] equal("","",true) true
It stops When it tries to load DUDBdtest... can anyone see wutz wrong with DUDB?? :

pawn Код:
#include <a_samp>
// for the samp stuff
#include <dutils>
// for the functions dini and dudb need
#include <dudb>
// for the userdatabase, get dudb version 1.2 for this.
#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1
#define COLOR_SYSTEM 0xEFEFF7AA



new PLAYERLIST_authed[MAX_PLAYERS];

public SystemMsg(playerid,msg[]) {
  if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
    SendClientMessage(playerid,COLOR_SYSTEM,msg);
  }
  return 1;
}

 public OnPlayerCommandText(playerid,cmdtext[]) {
 dcmd(login,5,cmdtext); // because login has 5 characters
 dcmd(register,8,cmdtext); // because register has 8 characters
 return false;
}

public OnPlayerConnect(playerid) {
 return false;
}

/*
 * This function will be useful when we need the playername
 * © by DracoBlue 2006
 */

public PlayerName(playerid) {
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
 return name;
}





/*
 * /register password
 *
 */

 dcmd_register(playerid,params[]) {

  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");

  // The command shouldn't work if an account with this
  // nick already exists
  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'.");

  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'");

  // We save the money to the accstate
  if (udb_Create(PlayerName(playerid),params,GetPlayerMoney(playerid),"")) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now.");
  return true;

 }




 /*
 * /login password
 *
 */

 dcmd_login(playerid,params[]) {

  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");

  // The command shouldn't work if an account with this
  // nick does not exists
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");

  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");

  if (udb_CheckLogin(PlayerName(playerid),params)) {
    // Login was correct

    // Since we are using the "accstate"-variable to save and
    // read the money of the player, we can update his money now.

    // Following thing is the same like the missing SetPlayerCommand
    GivePlayerMoney(playerid,udb_getAccState(PlayerName(playerid))-GetPlayerMoney(playerid));

    PLAYERLIST_authed[playerid]=true;

    return SystemMsg(playerid,"Successfully authed!");
  } else {
    // Login was incorrect
    return SystemMsg(playerid,"Login failed!");
  }
  return true;
 }




public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
   // Was loggedin, so save the data!
   udb_setAccState(PlayerName(playerid),GetPlayerMoney(playerid));
 }
 return false;
}
Reply
#36

Why do you use the "dtest"? I think you should compile the gamemode its self.
Reply
#37

Do i have to add something in the gamemode to get it workin?
Reply
#38

Not if you only want to save the money, BUT you should add the correct filterscript and not the dtest .
Reply
#39

how to save the money and score?

i want to save the money and score . all.

i tried many ways but i cant that

Reply
#40

The money only saves to file when they reigster. If they quit their money isnt saved to the file. I have already placed:

public OnPlayerDisconnect(playerid) {
if (PLAYERLIST_authed[playerid]) {
// Was loggedin, so save the data!
udb_setAccState(PlayerName(playerid),GetPlayerMone y(playerid));
}
return false;
}

Please help!
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)