Jump to content
  • 0

Problema KICK/BAN


d@rK

Question

La comenzile Kick/Ban cand ii dau sa zicem ban unui player, apare la tot serveru ca i-am dat ban, DAR celui caruia i-am dat ban Nu ii Arata, ii Arata doar "Server Closed Connection". As vrea sa ii apara si playerului care a luat ban... :D

Pawno(in GM):

1.Kick

[pawn]if(strcmp(cmd, "/kick", true) == 0)

{

    if(IsPlayerConnected(playerid))

    {

    tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /kick [playerid/PartOfName] [reason]");

return 1;

}

giveplayerid = ReturnUser(tmp);

if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pAgent] >= 1)

{

if(IsPlayerConnected(giveplayerid))

{

    if(giveplayerid != INVALID_PLAYER_ID)

    {

    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: /kick [playerid/PartOfName] [reason]");

return 1;

}

if(kicktime[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "Wait 10 seconds!");

new year, month,day;

getdate(year, month, day);

format(string, sizeof(string), "AdmCmd: %s a primit kick de la Adminul %s. Motiv: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year);

KickLog(string);

format(string, sizeof(string), "SERVER: {FF0000}%s {00FF00}a primit kick de la Adminul {FF0000}%s. {00FF00}Motiv: {FF00D9}%s", giveplayer, sendername, (result));

SendClientMessageToAll(COLOR_CAPONE, string);

                        format(string, sizeof(string), "Ai primit kick de la Adminul %s. Motiv: %s",sendername,(result));

                        SendClientMessage(giveplayerid, COLOR_RED, string);

kicktime[playerid] = 1;

            SetTimerEx("kickt", 10000, 0, "%d", playerid);

Kick(giveplayerid);

return 1;

}

}

}

else

{

format(string, sizeof(string), "%d is not an active player.", giveplayerid);

SendClientMessage(playerid, COLOR_GRAD1, string);

}

}

return 1;

}[/pawn]

2. Ban

[pawn]if(strcmp(cmd, "/ban", true) == 0)

{

    if(IsPlayerConnected(playerid))

    {

    tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ban [playerid/PartOfName] [reason]");

return 1;

}

giveplayerid = ReturnUser(tmp);

if (PlayerInfo[playerid][pAdmin] >= 5)

{

    if(IsPlayerConnected(giveplayerid))

    {

        if(giveplayerid != INVALID_PLAYER_ID)

        {

    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: /ban [playerid/PartOfName] [reason]");

return 1;

}

if(bantime[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "Are you trying to ban this server?");

new year, month,day;

getdate(year, month, day);

format(string, sizeof(string), "AdmCmd: %s a fost banat de catre Adminul %s. Motiv: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year);

BanLog(string);

format(string, sizeof(string), "SERVER: {FF0000}%s {00FF00}a fost banat de catre Adminul {FF0000}%s. {00FF00}Motiv: {FF00D9}%s", giveplayer, sendername, (result));

SendClientMessageToAll(COLOR_CAPONE, string);

                        new playersip[256];

GetPlayerIp(giveplayerid,playersip, sizeof(playersip));

    SendClientMessage(giveplayerid,COLOR_GREEN,"|___________[bAN INFO]___________|");

            format(string, sizeof(string), "Numele tau este: %s.",giveplayer);

                        SendClientMessage(giveplayerid, COLOR_RED, string);

                        format(string, sizeof(string), "IP-ul tau este: %s.",playersip);

                        SendClientMessage(giveplayerid, COLOR_RED, string);

                        format(string, sizeof(string), "Ai fost banat de: %s.",sendername);

                        SendClientMessage(giveplayerid, COLOR_RED, string);

                        format(string, sizeof(string), "Motiv: %s.",(result));

                        SendClientMessage(giveplayerid, COLOR_RED, string);

                        format(string, sizeof(string), "Data: %d/%d/%d",day,month,year);

                        SendClientMessage(giveplayerid, COLOR_RED, string);

                        SendClientMessage(giveplayerid,COLOR_GREEN,"|___________[bAN INFO]___________|");

                        bantime[playerid] = 1;

            SetTimerEx("bant", 10000, 0, "%d", playerid);

Ban(giveplayerid);

return 1;

}

}

}

else

{

format(string, sizeof(string), "%d is not an active player.", giveplayerid);

SendClientMessage(playerid, COLOR_GRAD1, string);

}

}

return 1;

}[/pawn]

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

Uite un exemplu ce trebuie sa faci. Faci un public nou unde pui functia Ban. In comanda ta pui un timer ca dupa 3 secunde sa primeasca jucatorul ban, in timpul acela i se va afisa mesajul

[pawn]forward KickPublic(playerid);

public KickPublic(playerid) Kick(playerid);

stock KickWithMessage(playerid, color, message[])

{

    SendClientMessage(playerid, color, message);

    SetTimerEx("KickPublic", 1000, 0, "d", playerid); //Delay of 1 second before kicking the player so he recieves the message

}

public OnPlayerCommandText(playerid, cmdtext[])

{

    if(strcmp(cmdtext, "/kickme", true) == 0)

    {

        //Kicks the player who the executed this command

        KickWithMessage(playerid, 0xFF0000FF, "You have been kicked.");

        return 1;

    }

    return 0;

}[/pawn]

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

Imi da erori:

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(16105) : error 001: expected token: ")", but found "&"

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(16105) : error 029: invalid expression, assumed zero

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(16114) : error 001: expected token: ")", but found "&&"

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(16114) : error 029: invalid expression, assumed zero

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(37626) : error 035: argument type mismatch (argument 3)

C:\Users\Mihnea\Desktop\BloodZone\gamemodes\BloodZone.pwn(38240) : error 035: argument type mismatch (argument 3)

Linia 16105: stock KickWithMessage(playerid, color, message[])

Linia 16114: stock BanWithMessage(playerid, color, message&[])

Linia 37626: KickWithMessage(playerid, 0xFF0000FF, "Ai primit kick de la Admin!");

Linia 38240: BanWithMessage(playerid, 0xFF0000FF, "Ai primit ban de la Admin!");

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.