AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with task (https://forums.alliedmods.net/showthread.php?t=132431)

CrazyChickenTest 07-15-2010 03:41

Need help with task
 
Hi. I need help with two task. I try do in code that if you dead others your team mates can revival you but they have only 15 seconds to do it! I have code with one of plugin on this forum. And how can I must edit it to my idea?
It's code here:
Code:

public event_death()
{
    new id = read_data(2)
   
    reset_player(id)
    if(g_haskit[id])
    {
        g_haskit[id] = false
    }
   
    static Float:minsize[3]
    pev(id, pev_mins, minsize)
   
    if(minsize[2] == -18.0)
        g_wasducking[id] = true
    else
        g_wasducking[id] = false
   
    set_task(0.5, "task_check_dead_flag", id)
}

public task_check_dead_flag(id)
{
    if(!is_user_connected(id))
        return
   
    if(pev(id, pev_deadflag) == DEAD_DEAD)
        create_fake_corpse(id)
    else
        set_task(0.5, "task_check_dead_flag", id)
}

I think I must do it here but how?
Sry for my not good english

Mxnn 07-15-2010 13:36

Re: Need help with task
 
PHP Code:


#include <fakemeta>
new boolcan_revive[33]
public 
event_death()
{
    new 
id read_data(2)
    
    
reset_player(id)
    if(
g_haskit[id])
    {
        
g_haskit[id] = false
    
}
    
    static 
Float:minsize[3]
    
pev(idpev_minsminsize)
    
    if(
minsize[2] == -18.0)
        
g_wasducking[id] = true
    
else
        
g_wasducking[id] = false
    
    set_task
(0.5"task_check_dead_flag"id)
    
set_task(15"task_b"id)
}

public 
task_check_dead_flag(id)
{
    if(!
is_user_connected(id))
        return
    
    if(
pev(idpev_deadflag) == DEAD_DEAD)
        
create_fake_corpse(id)
    else
        
set_task(0.5"task_check_dead_flag"id)
}
  
public 
task_b(id) {
    
can_revive[id] = false


public 
round_start() 
      for (new 
i=1i<=get_maxplayers(); i++)
            if (
is_user_alive(i) && is_user_connected(i))
                   
can_revive[i] = true

//Now you have to check if player want to revive someone..
//I suppose that to revive someone you have to write in say "/revive [name]"
public plugin_init() {
      
register_event("HLTV","Event_StartRound","a","1=0","2=0")
      
register_clcmd("say /revive""sayrevive"ADMIN_ALL)
}

public 
sayrevive(idlevelcid) {
          if (!
cmd_access(idlevelcid3)
                    
//He put more of 3 arguments
                     
return PLUGIN_HANDLED
          
new data[32]
          
read_argv(2data31)
          if (!
is_user_alive(id) || is_user_alive(data))
                     
//Revived client are alive or reviver are dead
                     
return PLUGIN_HANDLED
          
new rid find_player("lb"data)
          if (!
rid)
                     
//Part of name doesn't found
                     
return PLUGIN_HANDLED
          
if (!can_revive[rid]) //If can revive is false
                     //15 seconds have passed
                     
return PLUGIN_HANDLED
          ExecuteHamB
(Ham_CS_RoundRespawnrid)
          
set_task(0.1,"revivePl",0,rid,2)    

          return 
PLUGIN_CONTINUE    
}

public 
revivePl(id

    
fm_DispatchSpawn(id
    if (
get_user_team(id)==1
    { 
        
fm_give_item(id,weapons[WEAPON_KNIFE]) 
        
fm_give_item(id,weapons[WEAPON_GLOCK18]) 
        
fm_give_item_x(id,ammo_9mm,2)
    } 
    else 
    { 
        
fm_give_item(id,weapons[WEAPON_KNIFE]) 
        
fm_give_item(id,weapons[WEAPON_USP]) 
        
fm_give_item_x(id,ammo_45acp,2
    }


Test it

CrazyChickenTest 07-15-2010 17:26

Re: Need help with task
 
thx it works Topic is ready for close ;)

ot_207 07-15-2010 18:24

Re: Need help with task
 
Quote:

Originally Posted by Mxnn (Post 1240347)
PHP Code:


#include <fakemeta>
new boolcan_revive[33]
public 
event_death()
{
    new 
id read_data(2)
    
    
reset_player(id)
    if(
g_haskit[id])
    {
        
g_haskit[id] = false
    
}
    
    static 
Float:minsize[3]
    
pev(idpev_minsminsize)
    
    if(
minsize[2] == -18.0)
        
g_wasducking[id] = true
    
else
        
g_wasducking[id] = false
    
    set_task
(0.5"task_check_dead_flag"id)
    
set_task(15"task_b"id)
}

public 
task_check_dead_flag(id)
{
    if(!
is_user_connected(id))
        return
    
    if(
pev(idpev_deadflag) == DEAD_DEAD)
        
create_fake_corpse(id)
    else
        
set_task(0.5"task_check_dead_flag"id)
}
  
public 
task_b(id) {
    
can_revive[id] = false


public 
round_start() 
      for (new 
i=1i<=get_maxplayers(); i++)
            if (
is_user_alive(i) && is_user_connected(i))
                   
can_revive[i] = true

//Now you have to check if player want to revive someone..
//I suppose that to revive someone you have to write in say "/revive [name]"
public plugin_init() {
      
register_event("HLTV","Event_StartRound","a","1=0","2=0")
      
register_clcmd("say /revive""sayrevive"ADMIN_ALL)
}

public 
sayrevive(idlevelcid) {
          if (!
cmd_access(idlevelcid3)
                    
//He put more of 3 arguments
                     
return PLUGIN_HANDLED
          
new data[32]
          
read_argv(2data31)
          if (!
is_user_alive(id) || is_user_alive(data))
                     
//Revived client are alive or reviver are dead
                     
return PLUGIN_HANDLED
          
new rid find_player("lb"data)
          if (!
rid)
                     
//Part of name doesn't found
                     
return PLUGIN_HANDLED
          
if (!can_revive[rid]) //If can revive is false
                     //15 seconds have passed
                     
return PLUGIN_HANDLED
          ExecuteHamB
(Ham_CS_RoundRespawnrid)
          
set_task(0.1,"revivePl",0,rid,2)    

          return 
PLUGIN_CONTINUE    
}

public 
revivePl(id

    
fm_DispatchSpawn(id
    if (
get_user_team(id)==1
    { 
        
fm_give_item(id,weapons[WEAPON_KNIFE]) 
        
fm_give_item(id,weapons[WEAPON_GLOCK18]) 
        
fm_give_item_x(id,ammo_9mm,2)
    } 
    else 
    { 
        
fm_give_item(id,weapons[WEAPON_KNIFE]) 
        
fm_give_item(id,weapons[WEAPON_USP]) 
        
fm_give_item_x(id,ammo_45acp,2
    }


Test it

Next time use fun, not fakemeta_util

Bugsy 07-15-2010 20:43

Re: Need help with task
 
Mxnn, that code doesn't even come close to compiling plus has many inefficiencies. Please only help others if you are sure you know what you're doing.


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

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