Help with y_ini?
#1

Hey guys, Avail here. Could use some help with y_ini saving.
When i /promote someone (i'm using zcmd btw) it should make aAdmin = [level], and it does actually do that.
But the thing is, it saves it incorrectly, so it doesn't work ingame.
It's supposed to look like this:
Код:
[data]
aPassword = 253756250
aCash = 45
aAdmin = 3
aKills = 0
aDeaths = 0
aBanned = 0
But it saves it like this ( and it doesn't load it up properly ingame D: )
Код:
aAdmin = 3
[data]
aPassword = 253756250
aCash = 45
aAdmin = 0
aKills = 0
aDeaths = 0
aBanned = 0
Any help would be appreciated !
Reply
#2

Write your promote code here!
Reply
#3

Код:
CMD:promote(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-4,""#COL_RED"Only rcon admins can set admin levels!");
    new id, level;
    if(sscanf(params,"ui",id,level)) return SendClientMessage(playerid,-1,""#COL_RED"[SERVER] "#COL_GRAY"Usage: /setlevel <id> <level>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-4,""#COL_RED"That player is not connected!");
    new file[64],PlayerYName[24];
    GetPlayerName(id,PlayerYName,sizeof PlayerYName);
    format(file,sizeof file,"aAdmin/Users/%s.ini",PlayerYName);
    if(!fexist(file)) return SendClientMessage(playerid,-4,""#COL_RED"That player is not registered");
    new INI:File = INI_Open(UserPath(id));
    INI_WriteInt(File,"aAdmin",level);
    INI_Close(File);
    //pInfo[id][aAdmin] = level;
    SendClientMessage(playerid,-1,""#COL_RED"You have changed the selected user's admin level");
    SendClientMessage(id,-1,""#COL_RED"Your admin level has been changed");
    return 1;
}
Reply
#4

First type [pawn] then paste your code then type [/"pawn"] (Without ")
Reply
#5

pInfo [ id ][ aAdmin ] = level;

Should work, why you commented this!?!
Reply
#6

pawn Код:
CMD:promote(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-4,""#COL_RED"Only rcon admins can set admin levels!");
    new id, level;
    if(sscanf(params,"ui",id,level)) return SendClientMessage(playerid,-1,""#COL_RED"[SERVER] "#COL_GRAY"Usage: /setlevel <id> <level>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-4,""#COL_RED"That player is not connected!");
    new file[64],PlayerYName[24];
    GetPlayerName(id,PlayerYName,sizeof PlayerYName);
    format(file,sizeof file,"aAdmin/Users/%s.ini",PlayerYName);
    if(!fexist(file)) return SendClientMessage(playerid,-4,""#COL_RED"That player is not registered");
    pInfo[id][aAdmin] = level;
    new INI:File = INI_Open(UserPath(id));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"aAdmin",pInfo[id][aAdmin]);
    INI_Close(File);
    SendClientMessage(playerid,-1,""#COL_RED"You have changed the selected user's admin level");
    SendClientMessage(id,-1,""#COL_RED"Your admin level has been changed");
    return 1;
}
Try it...
Reply
#7

Код:
.pwn(709) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
.pwn(709) : warning 215: expression has no effect
.pwn(709) : error 001: expected token: ";", but found "]"
.pwn(709) : error 029: invalid expression, assumed zero
.pwn(709) : fatal error 107: too many error messages on one line
This line : pInfo[id][aAdmin] = level;
Reply
#8

new pInfo [MAX_PLAYERS] [ PlayerInfo ];
Reply
#9

pawn Код:
CMD:promote(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new id, level;
        if(sscanf(params,"ui",id,level)) return SendClientMessage(playerid, COL_RED, "[SERVER] Usage: /setlevel <id> <level>");
        if(IsPlayerConnected(id))
        {
            new string[64], pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(string, sizeof string, "%s has been promote to administrator level: %d.", pName, level);
            SendClientMessageToAll(GREEN, string);
            pInfo[id][aAdmin] = level;
            GameTextForPlayer(id, "Congratulations. You are promoted.", 3000, 6);
        }
        else return SendClientMessage(playerid, COL_RED, "That player is not connected!");
    }
    else return SendClientMessage(playerid ,COL_RED, "Only rcon admins can set admin levels!");
}
Try this...
Reply
#10

C:C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(59) : error 008: must be a constant expression; assumed zero
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(59) : error 021: symbol already defined: "pInfo"
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(710) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(710) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(710) : error 001: expected token: ";", but found "]"
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(710) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\SAMP 0.3d SERV\gamemodes\availworldwide.pwn(710) : fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)