Made /kick Command to Kick Player from Virtual World...
#1

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:

pawn Код:
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?
Reply
#2

Your *client message* code was totally wrong
PHP код:
CMD:ekick(playeridparams[]) {
    if (
pInfo[playerid][pWSELevel]> ) return 0;
    if ( 
GetPlayerVirtualWorldplayerid ) != ) return SendClientMessageplayeridCOLOR_RED"[ ! ] You can't use Event Commands in Real World !" );
    if (
sscanf(params"u"playerid)) return SendClientMessage(playeridCOLOR_LIGHTGREEN"[ ! ] USAGE: /ekick <playerid>");
    new 
idgiveplayerid,
        
PlayerNameMAX_PLAYER_NAME ], str_[100];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
    if( 
GetPlayerVirtualWorldplayerid ) != ) return SendClientMessageplayeridCOLOR_RED"[ ! ] This Player is not in Event !" );
    
SetPlayerVirtualWorld(id0);
    
    
format(str_62"[ ! ] %s has been kicked out from the event !"PlayerName);
    
SendClientMessageToAll(COLOR_PURPLEstr_);
    
format(str_sizeof str_"[ ! ] You have kicked %s from Event !"PlayerName);
    
SendClientMessage(playeridCOLOR_PURPLEstr_);
    
SendClientMessage(giveplayeridCOLOR_PURPLE"[ ! ] You have been kicked out from the Event !");
    return 
1;

Reply
#3

@=KempeR=: You are doing it wrong. Here it's the final version:
pawn Код:
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;
}
Reply
#4

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
Reply
#5

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
@=KempeR=: You are doing it wrong. Here it's the final version:
pawn Код:
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..
Reply
#6

Well, Thank you both. Now Please Fix my /elist Command.
And It is here:

pawn Код:
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
Reply
#7

Here are the changes:
Quote:
Originally Posted by =KempeR=
Посмотреть сообщение
pawn Код:
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);
Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
pawn Код:
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:
pawn Код:
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", "" );
}
Reply
#8

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
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)
Reply
#9

Quote:
Originally Posted by MAFIAWARS
Посмотреть сообщение
Well, Thank you both. Now Please Fix my /elist Command.
And It is here:

pawn Код:
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?
Reply
#10

Quote:
Originally Posted by MAFIAWARS
Посмотреть сообщение
Help?
Change
Код:
GetPlayerName( playerid, PlayerName, sizeof (PlayerName) );
To
Код:
GetPlayerName( pl, PlayerName, sizeof (PlayerName) );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)