Help with Offline set cash
#1

I tried to script a offline set cash for player but it seems does not works.Can anyone help me solve this and tell me exactly what to do?

pawn Код:
CMD:osetcash(playerid,params[])
{
    new string[124],string2[128], output[128];
    if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SCM(playerid, COLOR_LIGHTRED,"You are not authorized to use this command");
    format(string,sizeof(string),"Users/%s.ini",params,output);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", PlayerInfo[playerid][pCash]);
        INI_Close(File);
        format(string2, sizeof(string2), "{FFFF33}[Admin-Warning]{FF0000}: {FFFFFF}%s has Offline give cash to %s.", GetPlayerNameEx(playerid), params,output);
        AdminBroadCast(COLOR_LIGHTRED, string2);
    }
    else SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::..");
    return 1;
}
Reply
#2

Firstly.

Use sscanf (for better parameters and usage).

pawn Код:
CMD:osetcash(playerid,params[])
{
    new name[100], amount;
    if(sscanf(params,"s[100]d", name, amount)) return SendClientMessage(playerid, 0xFF0000FF,"Syntax: /osetcash [name][amount]");
    new string[128];
    format(string,sizeof(string),"Users/%s.ini",name);
    if(fexist(name))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", amount);
        INI_Close(File);
    }
    else { SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::.."); }
    return 1;
}
Edit the above according to your need! thats just an example.
Reply
#3

Quote:
Originally Posted by Jarnu
Посмотреть сообщение
Firstly.

Use sscanf (for better parameters and usage).

pawn Код:
CMD:osetcash(playerid,params[])
{
    new name[100], amount;
    if(sscanf(params,"s[100]d", name, amount)) return SendClientMessage(playerid, 0xFF0000FF,"Syntax: /osetcash [name][amount]");
    new string[128];
    format(string,sizeof(string),"Users/%s.ini",name);
    if(fexist(name))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", amount);
        INI_Close(File);
    }
    else { SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::.."); }
    return 1;
}
Edit the above according to your need! thats just an example.
I tried your example but it says Account not found when i type.its fail to set user file cash amout :/
Command = /osetcash Name amount.
i modify like this

pawn Код:
CMD:osetcash(playerid,params[])
{
    new name[100], amount;
    if(PlayerInfo[playerid][pAdmin] >= 4)
    if(sscanf(params,"s[100]d", name, amount)) return SendClientMessage(playerid, 0xFF0000FF,"Syntax: /osetcash [name][amount]");
    new string[128];
    format(string,sizeof(string),"Users/%s.ini",name);
    if(fexist(name))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", amount);
        INI_Close(File);
        format(string, sizeof(string), "{FFFF33}[Admin-Warning]{FF0000}: {FFFFFF}%s has Offline give cash to %s.", GetPlayerNameEx(playerid), params,amount);
        AdminBroadCast(COLOR_LIGHTRED, string);
    }
    else { SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::.."); }
    return 1;
}
Reply
#4

if(fexist(string))
Reply
#5

Quote:
Originally Posted by cosbraa
Посмотреть сообщение
if(fexist(string))
i just changed that thing.its still can't find the users.ini in scriptfile.
here is the new one i change.
pawn Код:
CMD:osetcash(playerid,params[])
{
    new name[100], amount;
    if(PlayerInfo[playerid][pAdmin] >= 4)
    if(sscanf(params,"s[100]d", name, amount)) return SendClientMessage(playerid, 0xFF0000FF,"Syntax: /osetcash [name][amount]");
    new string[128];
    format(string,sizeof(string),"Users/%s.ini",params);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", amount);
        INI_Close(File);
        format(string, sizeof(string), "{FFFF33}[Admin-Warning]{FF0000}: {FFFFFF}%s has Offline give cash to %s.", GetPlayerNameEx(playerid), params,amount);
        AdminBroadCast(COLOR_LIGHTRED, string);
    }
    else { SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::.."); }
    return 1;
}
Reply
#6

pawn Код:
format(string,sizeof(string),"Users/%s.ini",name);
Reply
#7

This should work.
pawn Код:
CMD:osetcash(playerid,params[])
{
    if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SCM(playerid, COLOR_LIGHTRED,"You are not authorized to use this command");
    new
        _name[ 24 ],
        _cash
    ;
    if(sscanf(params, "s[24]d", _name, _cash)) return SCM(playerid, COLOR_LIGHTRED,"Usage: /osetcash <Name> <Cash>");
    new
        string[ 32 ]
    ;
    format(string,sizeof(string),"Users/%s.ini",_name);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", _cash);
        INI_Close(File);
        // I don't really understand that message
    }
    else SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::..");
    return 1;
}
The params will be <name cash>, there is no such a file with name cash.ini. What the message [Admin-Warning] should do, because I left it.
Reply
#8

Quote:
Originally Posted by cosbraa
Посмотреть сообщение
pawn Код:
format(string,sizeof(string),"Users/%s.ini",name);
Thank you lol that works.
Reply
#9

By the way, everyone sets the money to, not give money. You should get the cash + the money you give from command.
Reply
#10

Quote:
Originally Posted by Dwane
Посмотреть сообщение
This should work.
pawn Код:
CMD:osetcash(playerid,params[])
{
    if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SCM(playerid, COLOR_LIGHTRED,"You are not authorized to use this command");
    new
        _name[ 24 ],
        _cash
    ;
    if(sscanf(params, "s[24]d", _name, _cash)) return SCM(playerid, COLOR_LIGHTRED,"Usage: /osetcash <Name> <Cash>");
    new
        string[ 32 ]
    ;
    format(string,sizeof(string),"Users/%s.ini",_name);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash", _cash);
        INI_Close(File);
        // I don't really understand that message
    }
    else SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::..");
    return 1;
}
The params will be <name cash>, there is no such a file with name cash.ini. What the message [Admin-Warning] should do, because I left it.
i add that message line to tell all admin that one of admin uses the command to a player.This is to prevent admin to abuse their power.We can know admin uses the important command to abuse or in a legal way.Anyway thanks to all who help me and i'm learning much from Cassbra lol Thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)