file include to Y_INI or DINI or SQL
#5

thank you, if you can show me an example would be great, here is the config and the onplayerlogin from my gamemode, i mean i need to this only on this 2 files pen01.cfg and username.cer

EDIT: i mean only for users not for other things, i want to make it in sqlite for get a easier scripting with tops and stuff

PHP код:
public OnPlayerLogin(playerid,const string[])
{
    if (
gdebug >= 1){printf("DEBUG OnPlayerLogin(%d) (%s)", playerid,string);}
    new 
string2[64];
    new 
playername2[MAX_PLAYER_NAME];
    
//new password[64];
    
new tmp2[256];
    
/*
    if (gPlayerSpawned[playerid] == 1)
    {
        SetPlayerHealth(playerid,0.0);
    }
    */
    
GetPlayerName(playerid, playername2, sizeof(playername2));
    
format(string2, sizeof(string2), "%s.cer", playername2);
    new 
File: file = fopen(string2, io_read);
    if (
file)
    {
        new 
valtmp[128];
        
fread(file, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
        if (
gdebug){printf("DEBUG password from file= (%s) pass enterd =  (%s)",PlayerInfo[playerid][pPassword] ,string );}
        
//fread(file, valtmp);strmid(password, valtmp, 0, strlen(string), 255);
        
if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))// && (strlen(string) == strlen(password)))
        
{
            
fread(file, valtmp);PlayerInfo[playerid][pCash] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAccount] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAdmin] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pLevel] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pExp] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][gPupgrade] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pKills] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pCB] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pHW] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pSR] = strval(valtmp);DelPrint(valtmp);
            if(
PlayerInfo[playerid][pKills] < 0){PlayerInfo[playerid][pKills] = 0;}//patch
            
if(PlayerInfo[playerid][pCB] < 0){PlayerInfo[playerid][pCB] = 0;}//patch
            
if(PlayerInfo[playerid][pHW] < 0){PlayerInfo[playerid][pHW] = 0;}//patch
            
if(PlayerInfo[playerid][pSR] < 0){PlayerInfo[playerid][pSR] = 0;}//patch
            
fread(file, valtmp);PlayerInfo[playerid][pWA] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPEN] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun1] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun2] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun3] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun4] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun5] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pGun6] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo1] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo2] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo3] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo4] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo5] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pAmmo6] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pSHealth] = floatstr(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pHealth] = floatstr(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPos_x] = floatstr(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPos_y] = floatstr(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPos_z] = floatstr(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pInt] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pLocal] = strval(valtmp);DelPrint(valtmp);
            if(
PlayerInfo[playerid][pModel] == 264){fread(file, valtmp);PlayerInfo[playerid][pTeam] = strval(valtmp);DelPrint(valtmp);}else{fread(file, valtmp);}
            if(
PlayerInfo[playerid][pModel] == 264){fread(file, valtmp);PlayerInfo[playerid][pModel] = strval(valtmp);DelPrint(valtmp);}else{fread(file, valtmp);}
            
fread(file, valtmp);PlayerInfo[playerid][pPnumber] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPhousekey] = strval(valtmp);DelPrint(valtmp);
            
fread(file, valtmp);PlayerInfo[playerid][pPbiskey] = strval(valtmp);DelPrint(valtmp);
            
fclose(file);
            
ResetPlayerMoney(playerid);
            
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
            
//if (gdebug){printf("DEBUG phonenumber = %d",pnumber);}
            
if(PlayerInfo[playerid][pLevel] == -999) //autoban
            
{
                
Ban(playerid);
            }
            
SendClientMessage(playerid, COLOR_GREEN, "Welcome to Public Enemy: Los Santos Server, hope you will enjoy playing here.");
            
SendClientMessage(playerid, COLOR_YELLOW, "For more informations about this server check /help, /news & /credits");
            
SendClientMessage(playerid, COLOR_WHITE, "This server is a non-profit project, admins will be chosen when there will be players.");
            
SendClientMessage(playerid, COLOR_YELLOW, motd);
            
format(string2, sizeof(string2), "SERVER: Welcome %s",playername2);
            
SendClientMessage(playerid, COLOR_WHITE,string2);
            
SetPlayerWeapons(playerid);
            
printf("%s has logged in",playername2);
            if (
PlayerInfo[playerid][pAdmin] > 0)
            {
                
format(string2, sizeof(string2), "SERVER: You are logged in as a level %d admin",PlayerInfo[playerid][pAdmin]);
                
SendClientMessage(playerid, COLOR_WHITE,string2);
            }
            
SetSpawnInfo(playerid, 1, PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
   if(
gTeam[playerid] == 0)
            {
                
gTeam[playerid] = 3;
            }
            else
            {
                
gTeam[playerid] = PlayerInfo[playerid][pTeam];
            }
            
gPlayerLogged[playerid] = 1;
            if(
accountplay)
            {
                
gPlayerSpawned[playerid] = 0;
            }
            
//SpawnPlayer(playerid);
            
GetPlayerName(playerid, playername2, sizeof(playername2));
            
format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~y~   %s", playername2);
            
DateProp(playerid);
            
GameTextForPlayer(playerid, tmp2, 5000, 1);
            return 
1;
        }
        else
        {
            
ShowPlayerDialog(playerid, 9, DIALOG_STYLE_PASSWORD, "{076F13}Login your account", "{F0FF00}Welcome back,\n{FFFFFF}put your password here\nfor login in Public Enemy: Los Santos server.\n{FF0000}Wrong Password.", "Login", "");
            
printf("%s is hacking a password",playername2);
            
fclose(file);
            
//return 1;
        
}
        return 
1;
    }
    else
    {
        
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You do not have an account, create one");
        
ShowPlayerDialog(playerid, 10, DIALOG_STYLE_PASSWORD, "{076F13}Create an account", "{F0FF00}Welcome,\n{FFFFFF}choose your password\nfor register in Public Enemy: Los Santos server.", "Create", "");
    }
    return 
1;
} 
Reply


Messages In This Thread
file include to Y_INI or DINI or SQL - by sheNdjze - 05.04.2016, 21:24
Re: file include to Y_INI or DINI or SQL - by -CaRRoT - 05.04.2016, 21:27
Re: file include to Y_INI or DINI or SQL - by sheNdjze - 05.04.2016, 21:29
Re: file include to Y_INI or DINI or SQL - by -CaRRoT - 05.04.2016, 21:31
Re: file include to Y_INI or DINI or SQL - by sheNdjze - 05.04.2016, 21:34
Re: file include to Y_INI or DINI or SQL - by AndySedeyn - 05.04.2016, 21:49
Re: file include to Y_INI or DINI or SQL - by sheNdjze - 05.04.2016, 21:55

Forum Jump:


Users browsing this thread: 1 Guest(s)