Can I edit an opened file ? (fopen etc)
#1

Hey guys, I added an updates system to my roleplay script which I can add updates and every player can browse them

/addupdate:
PHP код:
CMD:addupdate(playeridparams[])
{
    new 
type;
       if(!
IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playeridCOLOR_GREY"You are not allowed to use this command.");
       if(
PlayerInfo[playerid][pAdmin] >= 7)
       {
        if(
sscanf(params"is[128]"typeparams))
        {
            
SendClientMessage(playeridCOLOR_WHITE"** [Usage]: /addupdate [type] [text]");
            
SendClientMessage(playeridCOLOR_WHITE"** [Types]: 1 = Implemented / 2 = BugFix / 3 = Need GMX / 4 = Update");
            return 
1;
        }
        if(
AntiAdv(playeridparams)) return 1;
        if(
type || type 4) return SendClientMessage(playeridCOLOR_WHITE"You've entered an inavlid update type.");
        if(
strlen(params) > 128) return SendClientMessage(playeridCOLOR_WHITE"Maximum characters limit is 128.");
        new 
Filefile fopen("updates.cfg"io_append), string[128];
        if(
type == 1)
        {
            
format(stringsizeof(string), "{088A08}[Implemented]{FFFFFF}: %s\r\n"params);
            
fwrite(filestring);
            
fclose(file);
        }
        else if(
type == 2)
        {
            
format(stringsizeof(string), "{B40404}[BugFix]{FFFFFF}: %s\r\n"params);
            
fwrite(filestring);
            
fclose(file);
        }
        else if(
type == 3)
        {
            
format(stringsizeof(string), "{FFFF00}[GMX Needed]{FFFFFF}: %s\r\n"params);
            
fwrite(filestring);
            
fclose(file);
        }
        else if(
type == 4)
        {
            
format(stringsizeof(string), "{DBA901}[Updated]{FFFFFF}: %s\r\n"params);
            
fwrite(filestring);
            
fclose(file);
        }
        
format(stringsizeof(string), "Attention: %s has added a new update, check it out using /updates."RPN(playerid));
        
SendClientMessageToAll(COLOR_LIGHTREDstring);
        
Log("logs/updates.log"string);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    }
       return 
1;

/updates:
PHP код:
CMD:updates(playeridparam[])
{
       if(!
IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playeridCOLOR_GREY"You are not allowed to use this command.");
    new 
string[128], Filefile fopen("updates.cfg"io_read), idx=1;
    if(
PlayerInfo[playerid][pLevel])
    {
        
SendClientMessage(playeridCOLOR_LIME"______________ American Life Roleplay Updates _____________");
        while(
fread(filestring))
        {
            
format(stringsizeof(string), "%s"string);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
idx ++;
        }
        
fclose(file);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not allowed to use this command.");
    }
    return 
1;

I wanted to ask, if I can create a code on my GMX stock that when I GMX, the GMX Needed updates are turned to Bug Fixes and the Update updates are turned to Implemented
Reply
#2

https://sampwiki.blast.hk/wiki/OnGameModeInit

If you're asking for someone to do this for you, this is not the right section.
https://sampforum.blast.hk/showthread.php?tid=447813
Reply
#3

Yeah seems like its the wrong place
Lock & Delete
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)