Raised This Month: $51 Target: $400
 12% 

how restart the game if a specific player is dead


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
predaaator
Member
Join Date: Nov 2008
Old 09-02-2010 , 01:01   how restart the game if a specific player is dead
Reply With Quote #1

hi i would like a plugin that, if any specific player get death, then the game restart

for example, if "Jhon" is dead, mp_restartgame 1

that request is for cs:s

thx!!
predaaator is offline
predaaator
Member
Join Date: Nov 2008
Old 09-03-2010 , 02:02   Re: how restart the game if a specific player is dead
Reply With Quote #2

i made something like that, but doesnt work...why?

public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath)
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim_id = GetEventInt(event, "userid")
new attacker_id = GetEventInt(event, "attacker")

new victim = GetClientOfUserId(victim_id)
new attacker = GetClientOfUserId(attacker_id)
if (victim == 'PREDAAATOR')
{
ServerCommand("mp_restartgame 1");
}
return Plugin_Handled;

}
predaaator is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 09-03-2010 , 02:43   Re: how restart the game if a specific player is dead
Reply With Quote #3

if you use [php] tags around your code it stays pretty.
furthermore this belongs in the scripting section.

like this:
PHP Code:
public OnPluginStart() {
  
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
  new 
victim GetClientOfUserId(GetEventInt(event"userid"));
  
  if (
victim == 'PREDAAATOR')
    
ServerCommand("mp_restartgame 1");

  return 
Plugin_Handled

it doesnt work because victim isnt the name of the player, but the id.
it should rather be like this:
PHP Code:
#pragma semicolon 1

public OnPluginStart() {
  
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
  new 
victim GetClientOfUserId(GetEventInt(event"userid"));
  
  
/*
  //by player name - this is not a good idea
  new String:sName[64];
  GetClientName(victim, sName, sizeof(sName));
  
  if (StrEqual(sName, "PREDAAATOR"))
    ServerCommand("mp_restartgame 1");
  */

  //by steam-id, this doesnt care about the players name
  
new String:sAuth[32];  
  
GetClientAuthString(victimsAuthsizeof(sAuth));

  if (
StrEqual(sAUTH"STEAM_0:1:23456"))
    
ServerCommand("mp_restartgame 1");
  

  return 
Plugin_Handled

__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 09-03-2010 at 02:45.
Thrawn2 is offline
predaaator
Member
Join Date: Nov 2008
Old 09-03-2010 , 13:59   Re: how restart the game if a specific player is dead
Reply With Quote #4

wow!!!...thx man, now it works ;)
predaaator is offline
Deven
AlliedModders Donor
Join Date: Jun 2009
Old 03-07-2015 , 01:48   Re: how restart the game if a specific player is dead
Reply With Quote #5

Quote:
Originally Posted by Thrawn2 View Post
if you use [php] tags around your code it stays pretty.
furthermore this belongs in the scripting section.

like this:
PHP Code:
public OnPluginStart() {
  
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
  new 
victim GetClientOfUserId(GetEventInt(event"userid"));
  
  if (
victim == 'PREDAAATOR')
    
ServerCommand("mp_restartgame 1");

  return 
Plugin_Handled

it doesnt work because victim isnt the name of the player, but the id.
it should rather be like this:
PHP Code:
#pragma semicolon 1

public OnPluginStart() {
  
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
  new 
victim GetClientOfUserId(GetEventInt(event"userid"));
  
  
/*
  //by player name - this is not a good idea
  new String:sName[64];
  GetClientName(victim, sName, sizeof(sName));
  
  if (StrEqual(sName, "PREDAAATOR"))
    ServerCommand("mp_restartgame 1");
  */

  //by steam-id, this doesnt care about the players name
  
new String:sAuth[32];  
  
GetClientAuthString(victimsAuthsizeof(sAuth));

  if (
StrEqual(sAUTH"STEAM_0:1:23456"))
    
ServerCommand("mp_restartgame 1");
  

  return 
Plugin_Handled

Is there a way to make it mp_restartgame when all players are dead?
Deven is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-07-2015 , 01:51   Re: how restart the game if a specific player is dead
Reply With Quote #6

Quote:
Originally Posted by Deven View Post
Is there a way to make it mp_restartgame when all players are dead?
Shouldn't that happen anyways?
Darkness_ is offline
Deven
AlliedModders Donor
Join Date: Jun 2009
Old 03-07-2015 , 02:05   Re: how restart the game if a specific player is dead
Reply With Quote #7

Quote:
Originally Posted by Darkness_ View Post
Shouldn't that happen anyways?
Yes but what i have is preventing it, long story..

Last edited by Deven; 03-07-2015 at 02:06.
Deven is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-07-2015 , 02:22   Re: how restart the game if a specific player is dead
Reply With Quote #8

Quote:
Originally Posted by Deven View Post
Yes but what i have is preventing it, long story..
PHP Code:
#pragma semicolon 1 

public OnPluginStart() { 
  
HookEvent("player_death"Event_PlayerDeath); 


public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { 
    new 
players 0;
    for (new 
1<= MaxClientsi++) {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i))
            continue;
        
players++;
    }
    if (
players == 0) { ServerCommand("mp_restartgame 1"); }
    return 
Plugin_Continue;

Darkness_ is offline
Deven
AlliedModders Donor
Join Date: Jun 2009
Old 03-07-2015 , 03:49   Re: how restart the game if a specific player is dead
Reply With Quote #9

Quote:
Originally Posted by Darkness_ View Post
PHP Code:
#pragma semicolon 1 

public OnPluginStart() { 
  
HookEvent("player_death"Event_PlayerDeath); 


public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { 
    new 
players 0;
    for (new 
1<= MaxClientsi++) {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i))
            continue;
        
players++;
    }
    if (
players == 0) { ServerCommand("mp_restartgame 1"); }
    return 
Plugin_Continue;

Thanks friend!
Deven is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 10:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode