PDA

View Full Version : Made /kick Command to Kick Player from Virtual World...


MAFIAWARS
28/09/2013, 11:47 AM
Hello !

I made a Command /ekick to Kick the Player from Event. I want these things...

1. ClientMessage should be shown to All Players that %s Player has been kicked out from the Event.
2. ClientMessage should be shown to that Player who has kicked "You have been kicked out from Event".
3. ClientMessage should also be shown to that Player who kicked victim, "You have kicked %s Player from The Event"

Problems:

But, I am facing Problems that is that, When I am setting in my script to that [%s] to show the Player name and When I am using /ekick Command in my Server, The Server is Crashing...

2. ClientMessagesToAll is showing also to those Players Who are not in Virtual Event.
3. And When I am kicking someplayer from Event so It is sending me Client Message too like that: "You have been kicked out from the event.

That is my /ekick Command:


CMD:ekick(playerid, params[])
{
if(pInfo[playerid][pWSELevel]> 1 ) return 0;
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !" );
if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
new id, giveplayerid;
new PlayerName[24], str_[100];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(id, 0);
format(str_, 62, "[ ! ] %s has been kicked out from the event !", PlayerName);
SendClientMessage(giveplayerid, COLOR_PURPLE, "[ ! ] You have kicked %s from Event !, PlayerName");
SendClientMessage(giveplayerid, COLOR_PURPLE, "[ ! ] You have been kicked out from the Event !");
SendClientMessageToAll(COLOR_PURPLE, str_);
return 1;
}


Help me in Solving Please?

=KempeR=
28/09/2013, 11:58 AM
Your *client message* code was totally wrong
CMD:ekick(playerid, params[]) {
if (pInfo[playerid][pWSELevel]> 1 ) return 0;
if ( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !" );
if (sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
new id, giveplayerid,
PlayerName[ MAX_PLAYER_NAME ], str_[100];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(id, 0);

format(str_, 62, "[ ! ] %s has been kicked out from the event !", PlayerName);
SendClientMessageToAll(COLOR_PURPLE, str_);
format(str_, sizeof str_, "[ ! ] You have kicked %s from Event !", PlayerName);
SendClientMessage(playerid, COLOR_PURPLE, str_);
SendClientMessage(giveplayerid, COLOR_PURPLE, "[ ! ] You have been kicked out from the Event !");
return 1;
}

Dragonsaurus
28/09/2013, 12:01 PM
@=KempeR=: You are doing it wrong. Here it's the final version:CMD:ekick(playerid, params[])
{
if(pInfo[playerid][pWSELevel]> 1 ) return 0;
if(GetPlayerVirtualWorld(playerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !");
new giveplayerid,
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
PlayerName[MAX_PLAYER_NAME], str_[100];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(GetPlayerVirtualWorld(giveplayerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(giveplayerid, 0);
format(str_, 62, "[ ! ] %s has been kicked out from the event !", PlayerName);
SendClientMessageToAll(COLOR_PURPLE, str_);
format(str_, sizeof str_, "[ ! ] You have kicked %s from Event !", PlayerName);
SendClientMessage(playerid, COLOR_PURPLE, str_);
SendClientMessage(giveplayerid, COLOR_PURPLE, "[ ! ] You have been kicked out from the Event !");
return 1;
}

MAFIAWARS
28/09/2013, 12:03 PM
Dear, As you gave me /elist Command in another Post, I have a Question about it.

When I am doing /elist, So it Spamming in Dialog Box like that:

Players in Event:

1. MAFIA_WARS
2. MAFIA_WARS
3. MAFIA_WARS
4. MAFIA_WARS
5. MAFIA_WARS
6. MAFIA_WARS
7.MAFIA_WARS
etc

=KempeR=
28/09/2013, 12:09 PM
@=KempeR=: You are doing it wrong. Here it's the final version:CMD:ekick(playerid, params[])
{
if(pInfo[playerid][pWSELevel]> 1 ) return 0;
if(GetPlayerVirtualWorld(playerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !");
new giveplayerid,
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
PlayerName[MAX_PLAYER_NAME], str_[100];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(GetPlayerVirtualWorld(giveplayerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(giveplayerid, 0);
format(str_, 62, "[ ! ] %s has been kicked out from the event !", PlayerName);
SendClientMessageToAll(COLOR_PURPLE, str_);
format(str_, sizeof str_, "[ ! ] You have kicked %s from Event !", PlayerName);
SendClientMessage(playerid, COLOR_PURPLE, str_);
SendClientMessage(giveplayerid, COLOR_PURPLE, "[ ! ] You have been kicked out from the Event !");
return 1;
}

I can not see any difference..

MAFIAWARS
28/09/2013, 12:11 PM
Well, Thank you both. Now Please Fix my /elist Command.
And It is here:


CMD:elist(playerid)
{
if(pInfo[playerid][pWSELevel] > 1) return 0;
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !" );
new bigString[ 512 ] = "{FFFFFF}Players in Event:",
PlayerName[ MAX_PLAYER_NAME ],
Playerid = -1,
PlayerCount = 0
;

while ( ++Playerid != MAX_PLAYERS ) {
if ( !IsPlayerConnected(playerid) || GetPlayerVirtualWorld( playerid ) != 1 ) continue;
GetPlayerName( Playerid, PlayerName, sizeof (PlayerName) );
format( bigString, sizeof(bigString), "%s\n%i)\t%24s\t(ID: %i)", bigString, ++PlayerCount, PlayerName, Playerid );
}
if ( !PlayerCount ) strcat( bigString, "There is no players in the Event" );
return ShowPlayerDialog( playerid, 1234, 0, "Players in event", bigString, "Close", "" );
}


It is Spamming my Dialog Box like that:

Players in Event:

1. MAFIA_WARS
2. MAFIA_WARS
3. MAFIA_WARS
4. MAFIA_WARS
5. MAFIA_WARS
6. MAFIA_WARS
7.MAFIA_WARS
etc

Dragonsaurus
28/09/2013, 12:12 PM
Here are the changes:
if (sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
new id, giveplayerid,
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(id, 0);


new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "[ ! ] USAGE: /ekick <playerid>");
if(GetPlayerVirtualWorld(giveplayerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] This Player is not in Event !" );
SetPlayerVirtualWorld(giveplayerid, 0);



Edit: Here is the /elist cmd:
CMD:elist(playerid)
{
if(pInfo[playerid][pWSELevel] > 1) return 0;
if(GetPlayerVirtualWorld(playerid) != 1) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !" );
new bigString[ 512 ] = "{FFFFFF}Players in Event:",
PlayerName[MAX_PLAYER_NAME],
PlayerCount = 0
;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i) || GetPlayerVirtualWorld(i) != 1) continue;
GetPlayerName(i, PlayerName, sizeof(PlayerName));
PlayerCount++;
format(bigString, sizeof(bigString), "%s\n%i)\t%24s\t\t\t(ID: %i)", bigString, PlayerCount, PlayerName, i);
}
if (!PlayerCount) strcat(bigString, "There are no players in the Event");
return ShowPlayerDialog(playerid, 1234, 0, "Players in event", bigString, "Close", "" );
}

=KempeR=
28/09/2013, 12:18 PM
Here are the changes:

ahh.. my inattention

@MAFIAWARS, and player ids are same?
It should looks like this:
Players in Event:
1) lol (ID: 0)
2) test (ID: 1)
3) rgr (ID: 2)
4) rrr (ID: 3)
5) 1337 (ID: 4)

MAFIAWARS
28/09/2013, 12:34 PM
No. It is not Same but my name is the Same...It is SPAMMING.

MAFIAWARS
28/09/2013, 12:44 PM
Well, Thank you both. Now Please Fix my /elist Command.
And It is here:


CMD:elist(playerid)
{
if(pInfo[playerid][pWSELevel] > 1) return 0;
if( GetPlayerVirtualWorld( playerid ) != 1 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Event Commands in Real World !" );
new bigString[ 512 ] = "{FFFFFF}Players in Event:",
PlayerName[ MAX_PLAYER_NAME ],
Playerid = -1,
PlayerCount = 0
;

while ( ++Playerid != MAX_PLAYERS ) {
if ( !IsPlayerConnected(playerid) || GetPlayerVirtualWorld( playerid ) != 1 ) continue;
GetPlayerName( Playerid, PlayerName, sizeof (PlayerName) );
format( bigString, sizeof(bigString), "%s\n%i)\t%24s\t(ID: %i)", bigString, ++PlayerCount, PlayerName, Playerid );
}
if ( !PlayerCount ) strcat( bigString, "There is no players in the Event" );
return ShowPlayerDialog( playerid, 1234, 0, "Players in event", bigString, "Close", "" );
}


It is Spamming my Dialog Box like that:

Players in Event:

1. MAFIA_WARS
2. MAFIA_WARS
3. MAFIA_WARS
4. MAFIA_WARS
5. MAFIA_WARS
6. MAFIA_WARS
7.MAFIA_WARS
etc

Help?

=KempeR=
28/09/2013, 01:57 PM
Help?

Change
GetPlayerName( playerid, PlayerName, sizeof (PlayerName) );
To
GetPlayerName( pl, PlayerName, sizeof (PlayerName) );

Mattakil
28/09/2013, 03:39 PM
I'd use foreach for this... If the player listed as "I" is in the same virtual world, and i !=playerid sendclientmessage..whatever