SA-MP Forums Archive
Saving BanReason using Y_INI - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving BanReason using Y_INI (/showthread.php?tid=595544)



Saving BanReason using Y_INI - Luicy. - 04.12.2015

Hello,
I need help with saving the Ban Reason using y_ini..
Code yet:
http://pastebin.com/g15dAu6v

Where I need to save ban reason:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPlayerWeapon(playerid) == 26)
    {
        if(pAntiHackSawnOff[playerid] == 0)
        {
            new name[MAX_PLAYER_NAME], BanReasonString[17], BanByString[10];
            GetPlayerName(playerid, name, sizeof(name));
            format(BanReasonString, sizeof(BanReasonString), "Sawn Off Hacking");
            format(BanByString, sizeof(BanByString), "Anti Hack");
            PlayerInfo[playerid][pBanned] = 1;
            PlayerInfo[playerid][pBanName] = name[playerid];
            PlayerInfo[playerid][pBanBy] = BanByString;
            PlayerInfo[playerid][pBanReason] = BanReasonString;

            ResetPlayerWeapons(playerid);
            ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffMessage, DIALOG_STYLE_MSGBOX, ""Dialog_Color_Red"Banned!", "[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.", "Appael", "Quit");
        }
    }
    return 1;
}
Please explain me how to do it.

Errors: http://prntscr.com/9aad10


Re: Saving BanReason using Y_INI - ATGOggy - 04.12.2015

Try this:
PHP код:
            format(PlayerInfo[playerid][pBanBy], sizeof(PlayerInfo[playerid][pBanBy]), "%s"  BanByString);
            
format(PlayerInfo[playerid][pBanReason], sizeof(PlayerInfo[playerid][pBanReason]), "%s",  BanReasonString); 
instead of:
PHP код:
            PlayerInfo[playerid][pBanBy] = BanByString;
            
PlayerInfo[playerid][pBanReason] = BanReasonString



Re: Saving BanReason using Y_INI - Luicy. - 04.12.2015

How will that save to the userfile if I may ask?


Re: Saving BanReason using Y_INI - ATGOggy - 04.12.2015

Okay, wait. I'll update this post.


Re: Saving BanReason using Y_INI - Luicy. - 04.12.2015

Update: Code didn't work,
pawn Код:
C:\Users\Noel\Desktop\SAMP\gamemodes\RolePlay.pwn(125) : error 001: expected token: "]", but found "-identifier-"
C:\Users\Noel\Desktop\SAMP\gamemodes\RolePlay.pwn(125) : warning 215: expression has no effect
C:\Users\Noel\Desktop\SAMP\gamemodes\RolePlay.pwn(125) : error 001: expected token: ";", but found "]"
C:\Users\Noel\Desktop\SAMP\gamemodes\RolePlay.pwn(125) : error 029: invalid expression, assumed zero
C:\Users\Noel\Desktop\SAMP\gamemodes\RolePlay.pwn(125) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Tried to edit it but couldn't fix it.


Re: Saving BanReason using Y_INI - ATGOggy - 04.12.2015

PHP код:
enum pInfo
{
    
pPassword,
    
pCash,
    
pAdmin,
    
pBanned,
    
pBanName[32],
    
pBanBy[24],
    
pBanReason[32],
    
Skin,
    
Float:Xpos,
    
Float:Ypos,
    
Float:Zpos,
    
Float:Anglelog
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
Float:XlogFloat:YlogFloat:ZlogFloat:Angle;
    
GetPlayerFacingAngle(playeridAngle);
        
GetPlayerPos(playeridXlogYlogZlog);
        
PlayerInfo[playerid][Xpos] = Xlog;
        
PlayerInfo[playerid][Ypos] = Ylog;
        
PlayerInfo[playerid][Zpos] = Zlog;
        
PlayerInfo[playerid][Anglelog] = Angle;
        new 
playerskin GetPlayerSkin(playerid);
    new 
INI:File INI_Open(UserPath(playerid));
        
INI_SetTag(File,"data");
        
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
        
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
        
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
        
INI_WriteString(File,"BanName",PlayerInfo[playerid][pBanName]);
        
INI_WriteString(File,"BanBy",PlayerInfo[playerid][pBanBy]);
        
INI_WriteString(File,"BanReason",PlayerInfo[playerid][pBanReason]);
        
INI_WriteInt(File,"Skin",playerskin);
    
INI_WriteFloat(File,"Xpos",PlayerInfo[playerid][Xpos]);
    
INI_WriteFloat(File,"Ypos",PlayerInfo[playerid][Ypos]);
    
INI_WriteFloat(File,"Zpos",PlayerInfo[playerid][Zpos]);
    
INI_WriteFloat(File,"Anglelog",PlayerInfo[playerid][Anglelog]);
        
INI_Close(File);
    return 
1;

EDIT: Fixed a mistake. Sorry.


Re: Saving BanReason using Y_INI - Luicy. - 04.12.2015

Thanks alot!
+Reputation for you.


Re: Saving BanReason using Y_INI - ATGOggy - 04.12.2015

You're welcome.