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

Solved Check if user is alive or is dead


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 08-08-2020 , 15:06   Check if user is alive or is dead
Reply With Quote #1

Hello guys
I have this camera plugin and i need help please
I want the plugin to change automatically to 3rd person when you die and back to first person when you are alive.
Can somebody help me with some code?
HTML Code:
#include <amxmodx>
#include <engine>
#include <amxmisc>

public plugin_init()
{
    register_plugin("Camera Changer", "1.0", "XunTric")
    register_menucmd(register_menuid("Choose Camera View"), 1023, "setview") 

    register_clcmd("say /cam", "chooseview")
    register_clcmd("say_team /cam", "chooseview")    
}

public client_putinserver( id )
{
         set_view(id, CAMERA_3RDPERSON)
         return PLUGIN_HANDLED
}

public plugin_modules()
{
    require_module("engine")
}

public plugin_precache()
{
    precache_model("models/rpgrocket.mdl")
}

public chooseview(id)
{
    new menu[192] 
    new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3 
    format(menu, 191, "Choose Camera View^n^n1. 3rd Person View^n2. Upside View^n3. Normall View^n^n0. Exit") 
    show_menu(id, keys, menu)      
    return PLUGIN_CONTINUE
}

public setview(id, key, menu)
{
    if(key == 0) {
         set_view(id, CAMERA_3RDPERSON)
         return PLUGIN_HANDLED
    }

    if(key == 1) {
         set_view(id, CAMERA_TOPDOWN)
         return PLUGIN_HANDLED
    }

    if(key == 2) {
         set_view(id, CAMERA_NONE)
         return PLUGIN_HANDLED
    }

    else {
         return PLUGIN_HANDLED
    }

    return PLUGIN_HANDLED
}

Last edited by Barlap; 08-09-2020 at 19:07.
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-08-2020 , 16:30   Re: Check if user is alive or is dead
Reply With Quote #2

1. You should remove plugin_modules() since it's deprecated https://www.amxmodx.org/api/amxmodx/plugin_modules
2. Make a bool and when player is dead, mark it as true and at the player spawn mark it as false.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-08-2020 , 16:32   Re: Check if user is alive or is dead
Reply With Quote #3

Quote:
Originally Posted by Barlap View Post
Hello guys
I have this camera plugin and i need help please
I want the plugin to change automatically to 3rd person when you die and back to first person when you are alive.
Can somebody help me with some code?
HTML Code:
#include <amxmodx>
#include <engine>
#include <amxmisc>

public plugin_init()
{
    register_plugin("Camera Changer", "1.0", "XunTric")
    register_menucmd(register_menuid("Choose Camera View"), 1023, "setview") 

    register_clcmd("say /cam", "chooseview")
    register_clcmd("say_team /cam", "chooseview")    
}

public client_putinserver( id )
{
         set_view(id, CAMERA_3RDPERSON)
         return PLUGIN_HANDLED
}

public plugin_modules()
{
    require_module("engine")
}

public plugin_precache()
{
    precache_model("models/rpgrocket.mdl")
}

public chooseview(id)
{
    new menu[192] 
    new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3 
    format(menu, 191, "Choose Camera View^n^n1. 3rd Person View^n2. Upside View^n3. Normall View^n^n0. Exit") 
    show_menu(id, keys, menu)      
    return PLUGIN_CONTINUE
}

public setview(id, key, menu)
{
    if(key == 0) {
         set_view(id, CAMERA_3RDPERSON)
         return PLUGIN_HANDLED
    }

    if(key == 1) {
         set_view(id, CAMERA_TOPDOWN)
         return PLUGIN_HANDLED
    }

    if(key == 2) {
         set_view(id, CAMERA_NONE)
         return PLUGIN_HANDLED
    }

    else {
         return PLUGIN_HANDLED
    }

    return PLUGIN_HANDLED
}
Try this
PHP Code:
public client_death(g_victim)
{
    if (
is_user_alive(g_victim))
        return 
PLUGIN_HANDLED;
    
    
set_view(g_victimCAMERA_3RDPERSON)
    
    return 
PLUGIN_CONTINUE;

Supremache is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 08-08-2020 , 18:02   Re: Check if user is alive or is dead
Reply With Quote #4

Quote:
Originally Posted by Barlap View Post
Hello guys
I have this camera plugin and i need help please
I want the plugin to change automatically to 3rd person when you die and back to first person when
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <hamsandwich> public plugin_init() {     register_plugin("Camera Changer", "3.0", "XunTric|SPiNX");     register_menucmd(register_menuid("Choose Camera View"), 1023, "setview");     RegisterHam(Ham_Spawn, "player", "client_putinserver", 1);     RegisterHam(Ham_Killed, "player", "client_death");     register_clcmd("say /cam", "chooseview", 0, "- displays camera menu");     register_clcmd("say_team /cam", "chooseview", 0, "- displays camera menu"); } public client_putinserver( Allstar ) {     if(is_user_bot( Allstar ) || is_user_hltv( Allstar ) )         return PLUGIN_HANDLED;     if(is_user_alive( Allstar ) )     {         set_view(Allstar, CAMERA_NONE);         console_cmd(Allstar, "default_fov 100");     }     return PLUGIN_CONTINUE; } public client_death(victim) {     if(!is_user_alive(victim))     {         set_view(victim, CAMERA_3RDPERSON);         console_cmd(victim, "default_fov 150");     }     return PLUGIN_CONTINUE; } public plugin_precache()     precache_model("models/rpgrocket.mdl") public chooseview(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     format(menu, charsmax(menu), "Choose Camera View^n^n1. 3rd Person View^n2. Upside View^n3. Normal View^n^n0. Exit")     show_menu(id, keys, menu)     return PLUGIN_CONTINUE } public setview(id, key, menu) {     if(key == 0) {          set_view(id, CAMERA_3RDPERSON)          return PLUGIN_HANDLED     }     if(key == 1) {          set_view(id, CAMERA_TOPDOWN)          return PLUGIN_HANDLED     }     if(key == 2) {          set_view(id, CAMERA_NONE)          return PLUGIN_HANDLED     }     else {          return PLUGIN_CONTINUE     } }
__________________

Last edited by DJEarthQuake; 07-29-2021 at 04:27. Reason: basic description was missing
DJEarthQuake is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-08-2020 , 18:30   Re: Check if user is alive or is dead
Reply With Quote #5

Quote:
Originally Posted by DJEarthQuake View Post
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <hamsandwich> public plugin_init() {     register_plugin("Camera Changer", "3.0", "XunTric|SPiNX");     register_menucmd(register_menuid("Choose Camera View"), 1023, "setview");     RegisterHam(Ham_Spawn, "player", "client_putinserver", 1);     RegisterHam(Ham_Killed, "player", "client_death");     register_clcmd("say /cam", "chooseview");     register_clcmd("say_team /cam", "chooseview"); } public client_putinserver( Allstar ) {     if(is_user_bot( Allstar ) || is_user_hltv( Allstar ) )         return PLUGIN_HANDLED;     if(is_user_alive( Allstar ) )         {             set_view(Allstar, CAMERA_NONE);             console_cmd(Allstar, "default_fov 100");         }     return PLUGIN_CONTINUE; } public client_death(victim) {     if(!is_user_alive(victim))         {             set_view(victim, CAMERA_3RDPERSON);             console_cmd(victim, "default_fov 150");         }     return PLUGIN_CONTINUE; } public plugin_precache() {     precache_model("models/rpgrocket.mdl") } public chooseview(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     format(menu, charsmax(menu), "Choose Camera View^n^n1. 3rd Person View^n2. Upside View^n3. Normal View^n^n0. Exit")     show_menu(id, keys, menu)     return PLUGIN_CONTINUE } public setview(id, key, menu) {     if(key == 0) {          set_view(id, CAMERA_3RDPERSON)          return PLUGIN_HANDLED     }     if(key == 1) {          set_view(id, CAMERA_TOPDOWN)          return PLUGIN_HANDLED     }     if(key == 2) {          set_view(id, CAMERA_NONE)          return PLUGIN_HANDLED     }     else {          return PLUGIN_CONTINUE     } }

Done. It's a plugin I use too.
I want to ask question: why there's is precache mode for rgproket in all camera versions ?
Because this plugin making red/white small rocket in my server at barrier block in zombie
basebuilder mod
PHP Code:
precache_model("models/rpgrocket.mdl"
Supremache is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 08-08-2020 , 21:13   Re: Check if user is alive or is dead
Reply With Quote #6

Because the set_view function creates an invisible rpgrocket model as a dummy when used to serve as a camera entity. If not precached, the server will crash. This has been fixed in 1.9 and is automatically precached.
__________________

Last edited by OciXCrom; 08-08-2020 at 21:17.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-08-2020 , 22:08   Re: Check if user is alive or is dead
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
Because the set_view function creates an invisible rpgrocket model as a dummy when used to serve as a camera entity. If not precached, the server will crash. This has been fixed in 1.9 and is automatically precached.
Okay, thanks i understand now
Supremache is offline
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 08-09-2020 , 05:26   Re: Check if user is alive or is dead
Reply With Quote #8

Thanks guys, is there a way to block the player canera only on "Locked chase cam" or "freelook"?
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-10-2020 , 20:33   Re: Check if user is alive or is dead
Reply With Quote #9

yeah search.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 11:12.


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