SA-MP Forums Archive
Need help with something. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help with something. (/showthread.php?tid=255760)



Need help with something. - Im_BanK - 17.05.2011

Hello, i want to know how to write in a player account if he is not Online.
Im creating a command /blacklist to write in the player account something like pBlackListed = 1 but i don't know how to do it.

Some help?

ty


Re: Need help with something. - Biesmen - 17.05.2011

Then use /blacklist [Username] instead of /blacklist [Playerid].
Username is a string.


Re: Need help with something. - Im_BanK - 17.05.2011

yea i know that but how will the /blacklist command will write inside a player account if he is not on the server?
can you show me an ex

ty


Re: Need help with something. - Elka_Blazer - 17.05.2011


Simple CMD , using strtok,strcmp,dini.
pawn Код:
if (strcmp(cmdtext,"/nameban",true) == 0)
{
     if(IsPlayerAdmin(playerid))
     {
           new tmp[256];
           tmp = strtok(cmdtext, idx);
           if(!strlen(tmp)) return 0;
           new name[MAX_PLAYER_NAME],target[256];
           GetPlayerName(strval(tmp),name,sizeof(name));
           format(target,sizeof(target),"%s.ini",name);
           dini_IntSet(target,"idiot",1);
     }
     return 1;
}



Re: Need help with something. - DeadAhead - 17.05.2011

You forgot what you need to place in OnPlayerConnect :P

target[256]. Are you goddamn crazy? You should read why not to use houmungous sizes. Maximum text message size is 128. - /nameban's lenght (7) The maximum string should be [121]
so, I suggest changing target[256] to target[121].

Also i prefer using this instead of GetPlayerName:
pawn Код:
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
Then add this in OnPlayerConnect:
[pawn]
if (dini_Int(PlayerName(playerid),"idiot")) Kick(playerid);
Kicks him for having a bad name.


Re: Need help with something. - Elka_Blazer - 17.05.2011

Dont try to make it look bad ..... Its just fine .
Trying to find the little problems .... lame .



Re: Need help with something. - Biesmen - 17.05.2011

Quote:
Originally Posted by Elka_Blazer
Посмотреть сообщение
Dont try to make it look bad ..... Its just fine .
Trying to find the little problems .... lame .
It is bad. Little problems? Do you realize if you use that huge amount for every variable, your server will lag like crazy?

1. Do not use DINI, it opens file, write/reads file and closes it every command.
2. Do NOT use strtok, use SSCANF.
3. USE DCMD/ZCMD


Re: Need help with something. - Im_BanK - 17.05.2011

so my command is like this:

pawn Код:
if(strcmp(cmd, "/blacklist", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /BlackList [Nume] [Motiv");
                return 1;
            }
            giveplayerid = strval(tmp);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /BlackList [Nume] [Motiv");
                    return 1;
                }
                new playername3[MAX_PLAYER_NAME];
                new string3[64];
                GetPlayerName(giveplayerid, playername3, sizeof(playername3));
                format(string3, sizeof(string3), "users/%s.ini", playername3);
                new File: hFile = fopen(playername3, io_write);
                if (hFile)
                {
                   PlayerInfo[playerid][pBlackList] = 1;
                   format(string, sizeof(string), "AdmCmd: %s a fost adaugat in BlackList de catre %s, Motiv: %s", giveplayer, sendername, (result));
                   BlackListLog(string);
                   format(string, sizeof(string), "AdmCmd: %s a fost adaugat in BlackList de catre %s, Motiv: %s", giveplayer, sendername, (result));
                   SendClientMessageToAll(COLOR_LIGHTRED, string);
                   fclose(hFile);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, " Doar adminii pot folosi aceasta comanda!!!");
                return 1;
            }
        }
        return 1;
    }
but is baning myself /blacklist myname non-rp name. = Im_BanK was added in the BlackList by Im_BanK , reason: non-rp name.

why is that happening>?

What can i do to ban the writed name.?


Re: Need help with something. - Im_BanK - 17.05.2011

No one common ...

i realy need this. can someone help me?
sorry for duble post.