Make a "Disconnected" troll
#1

How do I show a "player disconnected" on my death log and set that player to another virtual world so and mute him for 10 seconds so it seems like he is disconnected for real?

CMD: /fakekick [ID]

P.S. It's a troll command.

Any help appreciated.

Thank you.
Reply
#2

https://sampwiki.blast.hk/wiki/SendDeathMessage

PHP код:
SendDeathMessage(INVALID_PLAYER_IDplayerid201); 
https://sampwiki.blast.hk/wiki/SetPlayerVirtualWorld
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

^Thanks.
Reply
#4

Код:
 //top of script
 #include <a_samp>
 #include <zcmd>
 #include <sscanf>
new Mute[MAX_PLAYERS];

CMD:fakekick(playerid, params[])
{
        new ID, targetid;
        if (sscanf(params, "us[90]", ID)) return SendClientMessage(playerid, 0x1F36E0FF, "USAGE: /fakekick [Playerid/Name]");
        if (!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xF50A0AFF, "NOTICE: Player not found.");
        new string[128];
        format(string,sizeof(string),"%s has been kicked by %s for ****** Hacks", PlayerName(ID), PlayerName(playerid));
        SendClientMessageToAll(0xAA3333AA, string);
        SendClientMessage(ID, 0xAA3333AA, "Server closed the connection.");
        SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
        SetPlayerVirtualWorld(playerid, 2);
        Mute[targetid] =  1;
        return 1;
        }
public OnPlayerText(playerid, text[])
{
                if(Mute[playerid] >= 1)
	{
		return 0;
	}
    return 1;
}
PlayerName(playerid)
{
	new CName[24];
	GetPlayerName(playerid, CName, 24);
 	return CName;
}
Haven't tested the code because wrote in 2 mins but should work.
Reply
#5

You should stop the main chat messages too, to the player id, to be more realistic

Regards.
Reply
#6

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Код:
 //top of script
 #include <a_samp>
 #include <zcmd>
 #include <sscanf>
new Mute[MAX_PLAYERS];

CMD:fakekick(playerid, params[])
{
        new ID, targetid;
        if (sscanf(params, "us[90]", ID)) return SendClientMessage(playerid, 0x1F36E0FF, "USAGE: /fakekick [Playerid/Name]");
        if (!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xF50A0AFF, "NOTICE: Player not found.");
        new string[128];
        format(string,sizeof(string),"%s has been kicked by %s for ****** Hacks", PlayerName(ID), PlayerName(playerid));
        SendClientMessageToAll(0xAA3333AA, string);
        SendClientMessage(ID, 0xAA3333AA, "Server closed the connection.");
        SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
        SetPlayerVirtualWorld(playerid, 2);
        Mute[targetid] =  1;
        return 1;
        }
public OnPlayerText(playerid, text[])
{
                if(Mute[playerid] >= 1)
	{
		return 0;
	}
    return 1;
}
PlayerName(playerid)
{
	new CName[24];
	GetPlayerName(playerid, CName, 24);
 	return CName;
}
Haven't tested the code because wrote in 2 mins but should work.
You shouldn't post code written under 2 minutes and untested:

You're not using targetid:
PHP код:
new IDtargetid
What is the 's' specifier doing there? How did you even get to 90 cells for it?
PHP код:
if (sscanf(params"us[90]"ID)) 
You don't need 128 cells for that string. The maximum size of the formatted string is 85 characters.
PHP код:
new string[128]; 
This shouldn't be inside cmd_fakekick:
PHP код:
OnPlayerText(playeridtext[])
{
                if(
Mute[playerid] >= 1)
    {
        return 
0
    } 
For the sake of convenience (while it doesn't matter), you could declare mute as a boolean variable:
PHP код:
new bool:Mute[playerid
And then use it as so:
PHP код:
Mute[playerid] = true
PHP код:
Mute[playerid] = false
From true to false and false to true:
PHP код:
Mute[playerid] = !Mute[playerid]; 
PHP код:
if(Mute[playerid]) // Player is muted 
PHP код:
if(!Mute[playerid]) // Player is not muted 
Reply
#7

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
You shouldn't post code written under 2 minutes and untested:

You're not using targetid:
PHP код:
new IDtargetid
What is the 's' specifier doing there? How did you even get to 90 cells for it?
PHP код:
if (sscanf(params"us[90]"ID)) 
You don't need 128 cells for that string. The maximum size of the formatted string is 85 characters.
PHP код:
new string[128]; 
This shouldn't be inside cmd_fakekick:
PHP код:
OnPlayerText(playeridtext[])
{
                if(
Mute[playerid] >= 1)
    {
        return 
0
    } 
For the sake of convenience (while it doesn't matter), you could declare mute as a boolean variable:
PHP код:
new bool:Mute[playerid
And then use it as so:
PHP код:
Mute[playerid] = true
PHP код:
Mute[playerid] = false
From true to false and false to true:
PHP код:
Mute[playerid] = !Mute[playerid]; 
PHP код:
if(Mute[playerid]) // Player is muted 
PHP код:
if(!Mute[playerid]) // Player is not muted 
What are you saying about target id part?
OnPlayertext isn't also inside cmd? As I said this was written in 2 minutes and works just fine according to my knowledge.Also obviously we all know this could be written better but I just gave him an example how can it be done.
Reply
#8

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
What are you saying about target id part?
OnPlayertext isn't also inside cmd? As I said this was written in 2 minutes and works just fine according to my knowledge.Also obviously we all know this could be written better but I just gave him an example how can it be done.
The indentation is crap; it looked like it was inside cmd_fakekick. Nevertheless, it compiles without errors and warnings but that means nothing to the actual workings of it. You're assigning 'ID' to the id entered as a parameter and not targetid, thus this will not work as intended:
PHP код:
Mute[targetid] = 1
Plus, it does not take his third request in consideration:
Quote:
Originally Posted by OP
mute him for 10 seconds so it seems like he is disconnected for real
So no, it will not work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)