AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Check if user is alive or is dead (https://forums.alliedmods.net/showthread.php?t=326620)

Barlap 08-08-2020 15:06

Check if user is alive or is dead
 
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
}


Shadows Adi 08-08-2020 16:30

Re: Check if user is alive or is dead
 
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.

Supremache 08-08-2020 16:32

Re: Check if user is alive or is dead
 
Quote:

Originally Posted by Barlap (Post 2713562)
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;



DJEarthQuake 08-08-2020 18:02

Re: Check if user is alive or is dead
 
Quote:

Originally Posted by Barlap (Post 2713562)
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     } }

Supremache 08-08-2020 18:30

Re: Check if user is alive or is dead
 
Quote:

Originally Posted by DJEarthQuake (Post 2713581)
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"


OciXCrom 08-08-2020 21:13

Re: Check if user is alive or is dead
 
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.

Supremache 08-08-2020 22:08

Re: Check if user is alive or is dead
 
Quote:

Originally Posted by OciXCrom (Post 2713590)
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:)

Barlap 08-09-2020 05:26

Re: Check if user is alive or is dead
 
Thanks guys, is there a way to block the player canera only on "Locked chase cam" or "freelook"?

Natsheh 08-10-2020 20:33

Re: Check if user is alive or is dead
 
yeah search.


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

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