Guardado INI
#1

Bueno estaba haciendo un sistema de matanzas,pero lo que yo necesito hacer RS esto.
Cuando alguien mate se le cree un archivo INI y guarde el mensaje por ejemplo: %s mato a %s, y al hacer /matanzas ID le muestre lo que se guardo en el INI,por ejemplo:
%s mato a %s
/matanzas 83
El jugador %s a matado a %s
Y asн salga a los que matу,gracias
Reply
#2

Publica tu codigo.
Reply
#3

Publica tu codigo asi te podemos ayudar.
Reply
#4

No tengo el cуdigo, como dije anterior solo lo estaba haciendo y se Mr ocurriу esa idea y como usar en ese caso el INI
Reply
#5

Intenta algo y te ayudaremos.
Reply
#6

No puedo,porque ni tengo la idea de como hacer el cуdigo,por eso pedн ayuda..
Reply
#7

Se me ocurriу esto, bбsicamente es la idea lo que quiero presentarte no el cуdigo funcionando por si acaso.

PHP код:
new
    
QFA[MAX_PLAYERS][32];


public 
OnPlayerDisconnect(playeridreason)
{
    new
            
str[32];

    
format(strsizeof str"%s"user_files(playerid));
    if(!
isnull(str))
    {
         if(
fexist(str))
        {
              new
                
INI:file INI_Open(str);

            
INI_WriteString(file"QFA"QFA[playerid]);
            
INI_Close(file);
            return 
1;
        }
    }
    return 
1;
}

public 
OnPlayerSpawn(playerid)
{
    new
        
exist;

    if((
exist LoadPlayerQFA(playerid)) == -1// Archivo no existe, por ende setea su QFA a "nadie".
    

        if(
strcmp(QFA[userid], "Nadie")){
            
format(QFA[playerid], 32"Nadie");
        }
    }
    return 
1;
}

COMMAND:matanzas(playeridparams[])
{
    new
        
userid;
        
    if(
sscanf(params"u"userid))
        return 
0;

    if(!
IsPlayerConnected(userid))
        return 
0;

    if(
strcmp(QFA[userid], "Nadie"))
        return 
SendClientMessage(playerid, -1"Nadie ha matado a dicho jugador, es todo un pro.");
    
    new
        
str[64], name[MAX_PLAYER_ANAME];
        
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(strsizeof str"%s fue el ultimo que mato a %s"QFA[userid], name);
    
SendClientMessage(playerid, -1str);
    return 
1;
}

stock user_files(playerid)
{
    new
        
string[64],
        
name[MAX_PLAYER_NAME]
    ;
    
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(stringsizeof (string), "Matanzas/%s.ini"name);
    
    if(!
fexists(filename))
        
string[0] = '\0';

    return 
string;
}

// Carga las matanzas, agrega esto..
stock LoadPlayerQFA(playerid)
{
    new
        
str[54];
        
    
format(strsizeof str"%s"user_files(playerid));
    
    if(
isnull(str) || str[0] == '\0')
        return -
1;
        
    return 
INI_ParseFile(user_files(playerid),"loadaccount_%s", .bExtra true, .extra playerid);
}

forward loadaccount_userplayeridname[], value[]);
public 
loadaccount_userplayeridname[], value[])
{
    
INI_String("QFA"QFA[playerid], 32);
    return 
1;
}

public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        new
            
matador[MAX_PLAYER_NAME];
            
        
GetPlayerName(playeridmatadorMAX_PLAYER_NAME);
        
        
format(QFA[killerid], 32"%s"matador);
        
// ok. ...
    
}
    return 
1;

Reply
#8

Quote:
Originally Posted by _Zume
Посмотреть сообщение
Se me ocurriу esto, bбsicamente es la idea lo que quiero presentarte no el cуdigo funcionando por si acaso.

PHP код:
new
    
QFA[MAX_PLAYERS][32];
public 
OnPlayerDisconnect(playeridreason)
{
    new
            
str[32];
    
format(strsizeof str"%s"user_files(playerid));
    if(!
isnull(str))
    {
         if(
fexist(str))
        {
              new
                
INI:file INI_Open(str);
            
INI_WriteString(file"QFA"QFA[playerid]);
            
INI_Close(file);
            return 
1;
        }
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    new
        
exist;
    if((
exist LoadPlayerQFA(playerid)) == -1// Archivo no existe, por ende setea su QFA a "nadie".
    

        if(
strcmp(QFA[userid], "Nadie")){
            
format(QFA[playerid], 32"Nadie");
        }
    }
    return 
1;
}
COMMAND:matanzas(playeridparams[])
{
    new
        
userid;
        
    if(
sscanf(params"u"userid))
        return 
0;
    if(!
IsPlayerConnected(userid))
        return 
0;
    if(
strcmp(QFA[userid], "Nadie"))
        return 
SendClientMessage(playerid, -1"Nadie ha matado a dicho jugador, es todo un pro.");
    
    new
        
str[64], name[MAX_PLAYER_ANAME];
        
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(strsizeof str"%s fue el ultimo que mato a %s"QFA[userid], name);
    
SendClientMessage(playerid, -1str);
    return 
1;
}
stock user_files(playerid)
{
    new
        
string[64],
        
name[MAX_PLAYER_NAME]
    ;
    
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(stringsizeof (string), "Matanzas/%s.ini"name);
    
    if(!
fexists(filename))
        
string[0] = '\0';
    return 
string;
}
// Carga las matanzas, agrega esto..
stock LoadPlayerQFA(playerid)
{
    new
        
str[54];
        
    
format(strsizeof str"%s"user_files(playerid));
    
    if(
isnull(str) || str[0] == '\0')
        return -
1;
        
    return 
INI_ParseFile(user_files(playerid),"loadaccount_%s", .bExtra true, .extra playerid);
}
forward loadaccount_userplayeridname[], value[]);
public 
loadaccount_userplayeridname[], value[])
{
    
INI_String("QFA"QFA[playerid], 32);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        new
            
matador[MAX_PLAYER_NAME];
            
        
GetPlayerName(playeridmatadorMAX_PLAYER_NAME);
        
        
format(QFA[killerid], 32"%s"matador);
        
// ok. ...
    
}
    return 
1;

Gracias
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)