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

I cant get dcmd working, i get these errors:

Код:
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\pawno\include\cps.inc(140) : warning 208: function with tag result used before definition, forcing reparse
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(204) : error 017: undefined symbol "dcmd_login"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(205) : error 017: undefined symbol "dcmd_register"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(206) : error 017: undefined symbol "dcmd_kill"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(207) : error 017: undefined symbol "dcmd_stats"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(209) : error 017: undefined symbol "dcmd_register"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(213) : error 017: undefined symbol "params"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(214) : error 017: undefined symbol "params"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(217) : warning 225: unreachable code
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(217) : error 017: undefined symbol "dcmd_login"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(221) : error 017: undefined symbol "params"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(222) : error 017: undefined symbol "params"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(231) : warning 225: unreachable code
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(231) : error 017: undefined symbol "dcmd_kill"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(237) : warning 225: unreachable code
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(242) : error 017: undefined symbol "dcmd_login"
C:\Documents and Settings\Arnoldas\Desktop\samp02Xserver.win32\gamemodes\Project_v1.0.pwn(245) : error 017: undefined symbol "params"
I have defined dcmd at the top of the script.
Reply

scott show us what you did so we can help you easier
because if you read the error we just can say, that you didnt defined dcmd_login / dcmd_register / dcmd_kill / dcmd_stats / ... / params
Reply

C:\Users\User1\Desktop\Revolution SA-MP TESTING\Login.pwn(41) : error 017: undefined symbol "PLAYERLIST_authed"
C:\Users\User1\Desktop\Revolution SA-MP TESTING\Login.pwn(62) : error 017: undefined symbol "PLAYERLIST_authed"
C:\Users\User1\Desktop\Revolution SA-MP TESTING\Login.pwn(77) : error 017: undefined symbol "PLAYERLIST_authed"
C:\Users\User1\Desktop\Revolution SA-MP TESTING\Login.pwn(85) : error 021: symbol already defined: "OnPlayerConnect"
C:\Users\User1\Desktop\Revolution SA-MP TESTING\Login.pwn(89) : error 021: symbol already defined: "OnPlayerCommandText"

Can someone please help me , Message me on MSN or sumthin Armin-11@Live.com
Im new to GTA Server's but i have a 100/mbs connection and a really strong PC.
I already have a Forum setup with members i just need help setting the Server up
Reply

this is what i made:

I think i did it wright, becouse in a few time ago it was working for me, but now not. That hapened after windows re-instaling, i think.

FIXED
Reply

Here are some of your problems

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(login,5,cmdtext);
  dcmd(register,8,cmdtext);
  dcmd(kill,4,cmdtext);
  dcmd(stats,5,cmdtext);
 
  dcmd_register(playerid,params[])
    {
    if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
    if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'.");
    if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'");
    if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now.");
    return true;
  }
  dcmd_login(playerid,params[])
    {
    if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
    if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");
    if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");
    if (udb_CheckLogin(PlayerName(playerid),params))
        {
      GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
      PLAYERLIST_authed[playerid]=true;
 
      return SystemMsg(playerid,"Successfully authed!");
    }
    return SystemMsg(playerid,"Login failed!");
  }
    dcmd_kill(playerid,params[])
    {
        SetPlayerHealth(playerid, 0);
        SetPlayerArmour(playerid, 0);
        return 1;
    }
    if(strcmp(cmdtext,"/dokai",true) == 0)
    {
        SetPlayerPos(playerid,-1547.3585,124.7388,3.5547);
        return 1;
    }
  dcmd_login(playerid,params[])
    {
    new id, string[256], name[MAX_PLAYER_NAME];
      if(!strlen(params)) id = playerid;
    else id = strval(params);
 
        if(IsPlayerConnected(id))
        {
          GetPlayerName(id,name,MAX_PLAYER_NAME);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          format(string,sizeof(string),"%s :",name);
          SendClientMessage(playerid,COLOR_GREEN,string);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          format(string,sizeof(string),"Level: %d.",PlayerInfo[id][Level]);
          SendClientMessage(playerid,COLOR_LIME,string);
          format(string,sizeof(string),"EXP: %d.",PlayerInfo[id][EXP]);
          SendClientMessage(playerid,COLOR_YELLOW,string);
          format(string,sizeof(string),"Kills: %d.",PlayerInfo[id][Kills]);
          SendClientMessage(playerid,COLOR_GREEN,string);
          format(string,sizeof(string),"Deaths: %d.",PlayerInfo[id][Deaths]);
          SendClientMessage(playerid,COLOR_RED,string);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          return 1;
        }
    }
    return 0;
}
should be

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(login,5,cmdtext);
  dcmd(register,8,cmdtext);
  dcmd(kill,4,cmdtext);
  dcmd(stats,5,cmdtext);

  if(strcmp(cmdtext,"/dokai",true) == 0)
  {
        SetPlayerPos(playerid,-1547.3585,124.7388,3.5547);
        return 1;
  }
  return 0;
}

dcmd_register(playerid,params[])
{
    if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
    if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'.");
    if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'");
    if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now.");
    return true;
}

dcmd_login(playerid,params[])
{
    if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
    if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");
    if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");
    if (udb_CheckLogin(PlayerName(playerid),params))
    {
      GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
      PLAYERLIST_authed[playerid]=true;
 
      return SystemMsg(playerid,"Successfully authed!");
    }
    return SystemMsg(playerid,"Login failed!");
}

dcmd_kill(playerid,params[])
{
        SetPlayerHealth(playerid, 0);
        SetPlayerArmour(playerid, 0);
        return 1;
}
   
dcmd_login(playerid,params[])
{
    new id, string[256], name[MAX_PLAYER_NAME];
      if(!strlen(params)) id = playerid;
    else id = strval(params);
 
        if(IsPlayerConnected(id))
        {
          GetPlayerName(id,name,MAX_PLAYER_NAME);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          format(string,sizeof(string),"%s :",name);
          SendClientMessage(playerid,COLOR_GREEN,string);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          format(string,sizeof(string),"Level: %d.",PlayerInfo[id][Level]);
          SendClientMessage(playerid,COLOR_LIME,string);
          format(string,sizeof(string),"EXP: %d.",PlayerInfo[id][EXP]);
          SendClientMessage(playerid,COLOR_YELLOW,string);
          format(string,sizeof(string),"Kills: %d.",PlayerInfo[id][Kills]);
          SendClientMessage(playerid,COLOR_GREEN,string);
          format(string,sizeof(string),"Deaths: %d.",PlayerInfo[id][Deaths]);
          SendClientMessage(playerid,COLOR_RED,string);
          SendClientMessage(playerid,COLOR_BROWN,"===================================");
          return 1;
        }
}
dcmd_ functions are not commands but its a call to a dcmd_ function just think of it as calling stocks or publics

Try that and the repost the remaining errors
Reply

Thanks, fixed
Reply

i have
Код:
#define DUDB_FILE_PATH "\\fadmin\\users\\%s.dudb.sav"
#include <dudb>
on the top of my adminfs.

But when somebody use /register his account won't be created in this direction. it will be created in the scriptfiles
Reply

Quote:
Originally Posted by Flo_White
i have
Код:
#define DUDB_FILE_PATH "\\fadmin\\users\\%s.dudb.sav"
#include <dudb>
on the top of my adminfs.

But when somebody use /register his account won't be created in this direction. it will be created in the scriptfiles
They have to be saved in the scriptfiles to make sa-mp io systems safe

pawn Код:
#include <dudb>
#define DUDB_FILE_PATH "fadmin/users/%s.dudb.sav"
Should work if the folders are created
Reply

You have to use this experimental 2.4.1. of dudb to use that feature:
Quote:
Originally Posted by DracoBlue
I do not expect that to work either ... .

Try (experimental - but should work) dudb 2.4.1: http://pastebin.ca/1262235

And then use instead of:
pawn Код:
#include <dudb>
do:
pawn Код:
#define DUDB_FILE_PATH "\\Drugs\\%s.dudb.sav"
#include <dudb>
- Draco
- Draco
Reply

ah it works now thanks
Reply

DracoBlue

Do you know a reason why my server would get 2 x files for one player?

I only noticed just now that I have

Soldan.dubd (this is the normal one)

But I also have this

Soldan.dubd.sav (PART filetype?)

So, in summary, I have two files for one player like so, in my /scriptfiles

Soldan.dubd
Soldan.dubd.sav


Both were edited by the script at the same time exactly 21:04:48 and both have exactly the same variables + values

Help? What is this bug?

For info, i have a 1 second timer that saves 50 approx values in that timer!

Thnx
Reply

Quote:
Originally Posted by BMUK
DracoBlue

Do you know a reason why my server would get 2 x files for one player?

I only noticed just now that I have

Soldan.dubd (this is the normal one)

But I also have this

Soldan.dubd.sav (PART filetype?)

So, in summary, I have two files for one player like so, in my /scriptfiles

Soldan.dubd
Soldan.dubd.sav


Both were edited by the script at the same time exactly 21:04:48 and both have exactly the same variables + values

Help? What is this bug?

For info, i have a 1 second timer that saves 50 approx values in that timer!

Thnx
You must look at OnPlayerConnect and OnPlayerDisconnect. There you must day in wich file it must be saved. If the The file at OnPlayerDisconnect is diffrent then the File of OnPlayerConnect then you know why you got two files./ Otherwise i dont knoe oo :P
Reply

All of my file changing functions carry the standard file-finding-function

Its the standard shizzle: [i]dUserSetINT(PlayerName(i)).("TaxesArrears",PropTaxArrears);

Its always going to be Soldan(playerid) there

I also dont have anything that will SET any variables in Connect/disconnect. Its all done in a timer although I dont see a reason for that to make a difference
Reply

Quote:
Originally Posted by BMUK
All of my file changing functions carry the standard file-finding-function

Its the standard shizzle: [i]dUserSetINT(PlayerName(i)).("TaxesArrears",PropTaxArrears);

Its always going to be Soldan(playerid) there

I also dont have anything that will SET any variables in Connect/disconnect. Its all done in a timer although I dont see a reason for that to make a difference
Saving user files in timers / OnPlayerUpdate is never needed. Just do it in onplayerconnect/disconnect. Your script will run faster.
Reply

The speed gain (if any) from moving it back to Connect/Disconnect wont be noticable to me or to the players so its fine where it is :P

Anyway, back to the question

Any idea why I would end up with two files for one player?

Soldan.dubd
Soldan.dubd.sav
Reply

Quote:
Originally Posted by DracoBlue
its a filterscript, why is the code big then?
heeeey! i got a problem ...how to use multi params ? forexample : /changepassword oldpass newpass? sorry im new to pawno .... but i have developed some personal scripts
Reply

Can some one please help me , when i convert this cool FS with my GM i get this :
Quote:

../include/gl_common.inc(75) : error 021: symbol already defined: "strtok"
../include/gl_common.inc(90) : error 047: array sizes do not match, or destination array is too small
../include/gl_common.inc(134) : error 021: symbol already defined: "isNumeric"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 29) : error 017: undefined symbol "PlayerName"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 87) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 92) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 107) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 110) : error 017: undefined symbol "dcmd_login"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 110) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 111) : error 017: undefined symbol "dcmd_register"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 111) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 112) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 115) : warning 225: unreachable code
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 115) : warning 217: loose indentation
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 115) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 115) : error 004: function "SystemMsg" is not implemented
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 116) : error 017: undefined symbol "msg"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 117) : error 017: undefined symbol "msg"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 119) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 122) : warning 225: unreachable code
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 122) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 122) : error 017: undefined symbol "PlayerName"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 125) : error 090: public functions may not return arrays (symbol "OnPlayerCommandText")
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 12 : warning 225: unreachable code
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 12 : warning 217: loose indentation
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 12 : error 017: undefined symbol "dcmd_register"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 130) : error 004: function "SystemMsg" is not implemented
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 130) : error 079: inconsistent return types (array & non-array)
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 131) : error 017: undefined symbol "PlayerName"
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 131) : error 004: function "SystemMsg" is not implemented
C:\DOCUME~1\Ivan\Desktop\BALKAN~1\GAMEMO~1\BL.pwn( 131) : error 079: inconsistent return types (array & non-array)

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


26 Errors.

Here the script if someone can please help
PS. i have translated some part of the FS and GM , i hope that is not a problem
Quote:

#include <a_samp>
#include <core>
#include <float>
#include <dudb>
#include <dutils>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#include "../include/gl_common.inc"

#define COLOR_SYSTEM 0xEFEFF7AA
#define green 0x33FF33AA
#define blue 0x00FFFFAA

forward OneSecTimer();

new PLAYERLIST_authed[MAX_PLAYERS];

main()
{
print("\n----------------------------------");
print(" Balkan Life script by ivan");
print("----------------------------------\n");


}

public OnPlayerRequestSpawn(playerid)
{
if (udb_Exists(PlayerName(playerid))){
if (!PLAYERLIST_authed[playerid]){
SendClientMessage(playerid,green,"Vi ste vec registrovani , upisite /login da se ulogujete !");
return 0;
}
}
return 1;
}

public OnGameModeInit()
{
// Lista skinova (skinID, pozicija1, pozicija2, pozicija3 , oruzije1, oruzije2, oruzije3, oruzije4, oruzije5, );
SetGameModeText("Balkan Life RP server");
AddPlayerClass(192, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(195, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(12, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(13, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(216, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(19, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(20, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(188, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(186, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(226, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(24, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(250, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(28, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(262, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(47, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(48, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(7, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(55, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 2498.9995,1149.3556,22.0232);
SetPlayerCameraPos(playerid, 2499.2422,1145.4624,22.0232);
SetPlayerCameraLookAt(playerid, 2498.9995,1149.3556,22.0232);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);

if (strcmp("/skripteri", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "____________Balkan Life Skripteri____________");
SendClientMessage(playerid, 0xFFFFFFFF, "Ivan_Pantovic");
SendClientMessage(playerid, 0xFFFFFFFF, "____________Balkan Life Skripteri____________");
return 1;
}

if(strcmp( cmd, "/vehicle", true ) == 0 )
{
if(!IsPlayerAdmin(playerid)) return 0;
{
new Float:X, Float:Y, Float:Z;
new tmp[256];
new created_vehicle_id;
tmp = strtok( cmdtext, idx );

GetPlayerPos( playerid, X, Y, Z );

created_vehicle_id = CreateVehicle( strval(tmp), X+2, Y+2, Z, 0, 0, 0, -1 );

new msg[256];
format(msg,256,"Created vehicle: %d",created_vehicle_id);
SendClientMessage(playerid,0xAAAAAAAA,msg);

return 1;
}
{
dcmd(login,5,cmdtext);
dcmd(register,8,cmdtext);
return 0;
}

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

stock PlayerName(playerid) {
new name[255];
GetPlayerName(playerid, name, 255);
return name;
}

dcmd_register(playerid,params[]) {

if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You have already had an account.");
if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"You have already created an account, /login [password] to login.");
if (strlen(params)==0) return SystemMsg(playerid,"USAGE: /register [password]");
if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"You have successfully created your account, now use /login [password] to login.");
return true;

}

dcmd_login(playerid,params[]) {

if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You have already logined.");
if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"You do not have an account, please /register [password]");
if (strlen(params)==0) return SystemMsg(playerid,"USAGE: /login [password]");
if (udb_CheckLogin(PlayerName(playerid),params)) {
SetPlayerScore(playerid,dUserINT(PlayerName(player id)).("score"));
SetPlayerMoney(playerid,dUserINT(PlayerName(player id)).("money"));
PLAYERLIST_authed[playerid]=true;
return SystemMsg(playerid,"You have successfully logined.");
}
return SystemMsg(playerid,"Wrong password or nickname!");
}
}
return 0;
}


public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
new string[48];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s se prikacio na server.", pName);
SendClientMessageToAll(0xAAAAAAAA, string);
return 1;
}
{
if (PLAYERLIST_authed[playerid]==0){
if (udb_Exists(PlayerName(playerid))){
SystemMsg(playerid,"Vec ste registrovani, upisite /login [sifra] da se ulogujete.");
}
else{ SystemMsg(playerid,"Vi niste registrovani, upisite /register [sifra] da se registrujete, a zatim /login [sifra] da se ulogujete!");
}

return 0;
}
return 1;
}

public OnPlayerDisconnect(playerid) {
if (PLAYERLIST_authed[playerid]) {
dUserSetINT(PlayerName(playerid)).("money",GetPlay erMoney(playerid));
dUserSetINT(PlayerName(playerid)).("score",GetPlay erScore(playerid));
}
PLAYERLIST_authed[playerid]=false;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new pName[MAX_PLAYER_NAME];
new string[56];
GetPlayerName(playerid, pName, sizeof(pName));

switch(reason)
{
case 0: format(string, sizeof(string), "%s je napustio server. (Prekid veze)", pName);
case 1: format(string, sizeof(string), "%s je napustio server. (Otisao)", pName);
case 2: format(string, sizeof(string), "%s je napustio server. (Kikovan)", pName);
}

SendClientMessageToAll(0xAAAAAAAA, string);
return 1;
}

Reply

Hey Draco, Can you help me out please?


I'm trying to make it that when a player registers his name is saved in a folder that is inside scriptfiles called "Folder" Right now it saves as a .dudb file in the scriptfiles folder.

Heres my /register and /login command



Код:
dcmd_register(playerid,params[]) {

  new plrip[128]; // The varyable
  GetPlayerIp(playerid,plrip,sizeof(plrip));
  // The command shouldn't work if we already are authed
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are already logged into your account");

  // The command shouldn't work if an account with this
  // nick already exists
  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");

  if (RegisterLoginDisabled == 1337) return SystemMsg(playerid,"New Account Registrations are Disabled. This is due to maintenance");
  // Did he forgot the password?
  if (strlen(params)==0) return SystemMsg(playerid,"Use: /register password to create a new account");

  // We save the money to the accstate
  if (udb_Create(PlayerName(playerid),params)) {

  dUserSetINT(PlayerName(playerid)).("money",7500);
  dUserSetINT(PlayerName(playerid)).("bankcash",5000);
  dUserSetINT(PlayerName(playerid)).("loancash",0);
  dUserSetINT(PlayerName(playerid)).("cashinsured",0);
  dUserSetINT(PlayerName(playerid)).("autobahnowner",0);
  dUserSetINT(PlayerName(playerid)).("regplayer",0);
  dUserSetINT(PlayerName(playerid)).("score",0);
  dUserSetINT(PlayerName(playerid)).("team",0);
  dUserSetINT(PlayerName(playerid)).("skin",0);
  dUserSetINT(PlayerName(playerid)).("jailtime",0);
  dUserSetINT(PlayerName(playerid)).("wallet",0);
  dUserSetINT(PlayerName(playerid)).("cork",0);
  dUserSetINT(PlayerName(playerid)).("drugs",0);
  dUserSetINT(PlayerName(playerid)).("drugbagy",0);
  dUserSetINT(PlayerName(playerid)).("adminlevel",0);
  dUserSetINT(PlayerName(playerid)).("teamkills",0);
  dUserSetINT(PlayerName(playerid)).("innocentkills",0);
  dUserSetINT(PlayerName(playerid)).("lowwantedkills",0);
  dUserSetINT(PlayerName(playerid)).("coprank",0);
  dUserSetINT(PlayerName(playerid)).("robrank",0);
  dUserSetINT(PlayerName(playerid)).("rpabusewar",0);
  dUserSetINT(PlayerName(playerid)).("deaths",0);
  dUserSetINT(PlayerName(playerid)).("casinorob",0);
  dUserSetINT(PlayerName(playerid)).("cashfromcasninorob",0);
  dUserSetINT(PlayerName(playerid)).("atmsrobbed",0);
  dUserSetINT(PlayerName(playerid)).("cashfromatmsrobbed",0);
  dUserSetINT(PlayerName(playerid)).("totaljailtime",0);
  dUserSetINT(PlayerName(playerid)).("finesissued",0);
  dUserSetINT(PlayerName(playerid)).("finespaid",0);
  dUserSetINT(PlayerName(playerid)).("nameban",0);
  dUserSetINT(PlayerName(playerid)).("timesinfected",0);
  dUserSetINT(PlayerName(playerid)).("timesraped",0);
  dUserSetINT(PlayerName(playerid)).("timesrobbed",0);
  dUserSetINT(PlayerName(playerid)).("timeshealed",0);
  dUserSetINT(PlayerName(playerid)).("timescured",0);
  dUserSetINT(PlayerName(playerid)).("hitsplaced",0);
  dUserSetINT(PlayerName(playerid)).("hitsplacedonyou",0);
  dUserSetINT(PlayerName(playerid)).("timessearched",0);
  dUserSetINT(PlayerName(playerid)).("drugssiezedbycops",0);
  dUserSetINT(PlayerName(playerid)).("canusearmy",0);
  dUserSetINT(PlayerName(playerid)).("connectedminute",0);
  dUserSetINT(PlayerName(playerid)).("connectedhour",0);
  dUserSetINT(PlayerName(playerid)).("timesfuckedoff",0);
  dUserSetINT(PlayerName(playerid)).("RegularPlayer",0);
  dUserSet(PlayerName(playerid)).("ipaddress",plrip);


	return SystemMsg(playerid,"Your Account has been created. Login with /login password now to log in (Before Spawn)");

   }
	return true;

 }
 dcmd_login(playerid,params[]) {

  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are already logged in");

  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account does not exist, please use /register password");

  if (strlen(params)==0) return SystemMsg(playerid,"Usage: /login password");

  if (udb_CheckLogin(PlayerName(playerid),params)) {

		GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
    SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("score")-GetPlayerScore(playerid));
    robberrank[playerid] =dUserINT(PlayerName(playerid)).("robrank");
    raperank[playerid] =dUserINT(PlayerName(playerid)).("raperank");
    tazerank[playerid] =dUserINT(PlayerName(playerid)).("tazerank");
    hitrank[playerid] =dUserINT(PlayerName(playerid)).("hitrank");
    arrestrank[playerid] =dUserINT(PlayerName(playerid)).("arrestrank");
    teamkiller[playerid] =dUserINT(PlayerName(playerid)).("teamkills");
    innocentkiller[playerid] =dUserINT(PlayerName(playerid)).("innocentkills");
    lowwantedkiller[playerid] =dUserINT(PlayerName(playerid)).("lowwantedkills");
    BankRobInsurance[playerid] =dUserINT(PlayerName(playerid)).("cashinsured");
    CanUseArmy[playerid] =dUserINT(PlayerName(playerid)).("canusearmy");
    PlayerAdminLevel[playerid] =dUserINT(PlayerName(playerid)).("adminlevel");
    RegularPlayer[playerid] =dUserINT(PlayerName(playerid)).("RegularPlayer");

    PLAYERLIST_authed[playerid]=true;

    return SystemMsg(playerid,"You are now logged in. Your stats will be auto-saved when you disconnect");
  }
  return SystemMsg(playerid,"Login Attempt Failed");
 }
Reply

Try this: http://forum.sa-mp.com/index.php?top...1840#msg511840

Have fun coding,
Draco
Reply

Quote:
Originally Posted by DracoBlue
Thank you for the quick response Draco, But It still did not work..

I put
Код:
#define DUDB_FILE_PATH "\\Drugs\\%s.dudb.sav"
#include <dudb>
At the top of my script (on top of #include <dudb> and it still did not save the players files into another folder. It saved it straight into scriptfiles.

I'm not sure if i did it wrong, but i pasted exactly what you told me too. Do i have to edit my register command by any chance?

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)