SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/11/2019, 03:13 PM   #1
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Thumbs up command to kill all players

hi how to make rcon admin command to kill all online players and say in chat admin alvin has killed all players

thanks.
alvin6 is offline   Reply With Quote
Old 02/11/2019, 03:15 PM   #2
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 102
Reputation: 4
Default Re: command to kill all players

Here you go.

PHP Code:
CMD:killall(playerid)
{
    new 
string[160], pName[MAX_PLAYERS];
    if(
IsPlayerAdmin(playerid))
    {
        for(new 
0GetPlayerPoolSize(); <= ji++)
        {
            
SetPlayerHealth(i0);
        }    
        
GetPlayerName(playeridpNamesizeof(pName));
        
format(stringsizeof(string), "Administrator %s has killed all players."pName);
        
SendClientMessageToAll(-1string);
    }    
    else 
SendClientMessage(playerid, -1"You are not authorized to use this command");

WalkZ is offline   Reply With Quote
Old 02/11/2019, 03:27 PM   #3
alvin6
Big Clucker
 
alvin6's Avatar
 
Join Date: Mar 2017
Posts: 58
Reputation: 2
Default Re: command to kill all players

not working it give error
Code:
error 017: undefined symbol "GetPlayerPoolSize'
alvin6 is offline   Reply With Quote
Old 02/11/2019, 03:37 PM   #4
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 87
Default Re: command to kill all players

Quote:
Originally Posted by alvin6 View Post
not working it give error
Code:
error 017: undefined symbol "GetPlayerPoolSize'
Update you'r pawno
__________________
Lokii is offline   Reply With Quote
Old 02/11/2019, 04:06 PM   #5
Unte99
Gangsta
 
Unte99's Avatar
 
Join Date: Jul 2010
Location: Lithuania
Posts: 628
Reputation: 65
Default Re: command to kill all players

Quote:
Originally Posted by WalkZ View Post
Here you go.

PHP Code:
CMD:killall(playerid)
{
    new 
string[160], pName[MAX_PLAYERS];
    if(
IsPlayerAdmin(playerid))
    {
        for(new 
0GetPlayerPoolSize(); <= ji++)
        {
            
SetPlayerHealth(i0);
        }    
        
GetPlayerName(playeridpNamesizeof(pName));
        
format(stringsizeof(string), "Administrator %s has killed all players."pName);
        
SendClientMessageToAll(-1string);
    }    
    else 
SendClientMessage(playerid, -1"You are not authorized to use this command");

pawn Code:
CMD:killall(playerid)
{
    new string[160], pName[MAX_PLAYERS];
    if(IsPlayerAdmin(playerid))
    {
        for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
        {
            if(IsPlayerConnected(i)) // You don't want to kill ghosts.
            {
                SetPlayerHealth(i, 0);
            }
        }
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string, sizeof(string), "Administrator %s has killed all players.", pName);
        SendClientMessageToAll(-1, string);
    }
    else SendClientMessage(playerid, -1, "You are not authorized to use this command");
}
Unte99 is offline   Reply With Quote
Old 02/11/2019, 04:13 PM   #6
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,478
Reputation: 1634
Default Re: command to kill all players

"You don't want to kill ghosts"
That doesn't matter at all, off course. However it is just good practice to not run functions on not connected players. It's a waste of runtime (even though that delay'd be very, very, very, very little for SetPlayerHealth).

Also @OP: Like they already told, update to 0.3.7
__________________
Do not click on this URL -It is secret information
RIP Slayer 1981-2019 \m/
Kwarde is offline   Reply With Quote
Old 02/11/2019, 04:20 PM   #7
Unte99
Gangsta
 
Unte99's Avatar
 
Join Date: Jul 2010
Location: Lithuania
Posts: 628
Reputation: 65
Default Re: command to kill all players

Quote:
Originally Posted by Kwarde View Post
"You don't want to kill ghosts"
That doesn't matter at all, off course. However it is just good practice to not run functions on not connected players. It's a waste of runtime (even though that delay'd be very, very, very, very little for SetPlayerHealth).

Also @OP: Like they already told, update to 0.3.7
https://forum.sa-mp.com/showthread.php?t=581727

It doesn't matter if this is only a little bit of code and the difference between the speeds would not change drastically, but you should always check if the player is connected. If you don't use IsPlayerConnected in your codes it's just bad optimization.
Unte99 is offline   Reply With Quote
Old 02/11/2019, 04:34 PM   #8
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,478
Reputation: 1634
Default Re: command to kill all players

Quote:
Originally Posted by Unte99 View Post
It doesn't matter if this is only a little bit of code and the difference between the speeds would not change drastically,
"(even though that delay'd be very, very, very, very little for SetPlayerHealth)". Jep.
Quote:
Originally Posted by Unte99 View Post
but you should always check if the player is connected. If you don't use IsPlayerConnected in your codes it's just bad optimization.
That's precisely what I meant with "However it is just good practice to not run functions on not connected players."
__________________
Do not click on this URL -It is secret information
RIP Slayer 1981-2019 \m/
Kwarde is offline   Reply With Quote
Old 02/11/2019, 07:56 PM   #9
WalkZ
Big Clucker
 
WalkZ's Avatar
 
Join Date: Oct 2019
Location: Pakistan
Posts: 102
Reputation: 4
Default Re: command to kill all players

Quote:
Originally Posted by alvin6 View Post
not working it give error
Code:
error 017: undefined symbol "GetPlayerPoolSize'
For this you need to upgrade server version to 0.3.7 and in case if you dont want to upgrade you can use this but i highly recommend to upgrade your version too.

PHP Code:
CMD:killall(playerid)
{
    new 
string[160], pName[MAX_PLAYERS];
    if(
IsPlayerAdmin(playerid))
    {
        for (new 
0MAX_PLAYERSi++)
        {
           if(
IsPlayerConnected(i))
           { 
              
SetPlayerHealth(i0);
           }   
        }    
        
GetPlayerName(playeridpNamesizeof(pName));
        
format(stringsizeof(string), "Administrator %s has killed all players."pName);
        
SendClientMessageToAll(-1string);
    }    
    else 
SendClientMessage(playerid, -1"You are not authorized to use this command");
    return 
1;

WalkZ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Player Money if kill other players PowerF Scripting Help 5 28/06/2014 11:07 AM
Unable to kill players during a tournament. rangerxxll Scripting Help 0 08/03/2014 01:46 AM
Save HP - only kill players ;/ .Error Scripting Help 0 23/03/2013 07:03 PM
Any idea players' most kill store in dini [ANGEL]_Rocko Scripting Help 13 07/11/2012 03:48 AM
[Help] Outside LS = Kill Players Jimbo01 Help Archive 4 14/01/2011 05:40 PM


All times are GMT. The time now is 12:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.