Raised This Month: $ Target: $400
 0% 

[REQ] Give Life


Post New Thread Reply   
 
Thread Tools Display Modes
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 07-17-2014 , 13:48   Re: [REQ] Give Life
Reply With Quote #11

Quote:
Originally Posted by HamletEagle
the plugin simply don't load
Further info,
I am using AMX Mod X 1.8.3 and Metamod v1.21.1-am.

My server.cfg serttings for logging errors,
log on
mp_logdetail 1
mp_logmessages 1
__________________

Last edited by jingojang; 07-17-2014 at 14:15.
jingojang is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-18-2014 , 05:26   Re: [REQ] Give Life
Reply With Quote #12

I'm using amxmodx 1.8.2 and everything is fine.Will check with 1.8.3

Last edited by HamletEagle; 07-18-2014 at 05:26.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-18-2014 , 06:17   Re: [REQ] Give Life
Reply With Quote #13

HamletEagle,
- why you formatex that szError message when you don't put any variables, strings, etc. in it. I think you can directly put the text in set_fail_state.
- there's a little typo in the command descriptions - both are "Give player lives"
- I think it's redundand to put a description in clcmd commands, since the user uses it only as it is
- and here I want to mention something about that check (I'm not sure and I want to ask)
PHP Code:
if ( equali szArg1 ], "CT" ) ) 
Isn't szArg1 [ 1 ] only one letter? I mean, about the size in the brackets. And therefore it should be like
PHP Code:
if ( equali szArg1 ], "C" ) ) 
. I'm not sure, feel free to explain with details
- why you save the data with player's name? I thought SteamID is the best of the bests
- I think this check
PHP Code:
if ( ! Target ) { 
            
            
console_print(id"Sorry, player %s could not be found !"szArg1 
            return 

            
        

is redundand, since the engine checks that itself. I mean, when you register concmd and define a cmd_target of it, this check becomes automatic and the console says it: "Player with that name or userid not found".

- I think that if you use "else" and "else if" statements, there's no need to return in the "if" statements. I mean, only one of the functions will be executed, so the returns aren't needed.

And I want to know, is the suggestion about respawning on the death point still actual and should someone make it.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-18-2014 , 08:54   Re: [REQ] Give Life
Reply With Quote #14

Ah, missed this, I was so tired when I wrote it.

1. No ideea why I use formatex.
2. Command description doesn't really count....
3. It's not reduntant, but I doesn't make a difference.
4. It means to start from cell 1, so it's not a char here.
5. After posting this I just realized that I writted it with name and wanted to change to steamid, but I forgot. Now it save by steamid.
6. No ideea why I check if the player is not in server.

PHP Code:
#include < amxmodx > 
#include < nvault > 
#include < amxmisc > 
#include < hamsandwich > 

#define RESPAWN_COMMAND "say /respawn" // Command to respawn.
#define CHECK_LIVES_COMMAND "say /lives" // Command to see how much lives do you have.

new g_iVaultPlayerLives 33 

public 
plugin_init ( ) { 
    
    
register_plugin "Lives""1.0""HamletEagle" 
    
    
g_iVault nvault_open "LivesVault" 
    
    if ( 
g_iVault == INVALID_HANDLE 
        
set_fail_state"Error opening vault file" 
    
    
register_concmd "amx_give_lives""CmdGiveLives"ADMIN_SLAY"|--Give lifes to a player" 
    
register_concmd "amx_take_lives""CmdTakeLives"ADMIN_SLAY"|--Give lifes to a player" 
    
    
register_clcmd CHECK_LIVES_COMMAND"ClCmdCheckLives", -1"|-- Check your lives" )
    
register_clcmd RESPAWN_COMMAND "ClCmdLive", -1"|-- Use a live" 


public 
plugin_end ( ) 
    
nvault_close g_iVault 

public 
client_connect id )  
    
LoadLives id 

public 
client_disconnect id )     
    
SaveLives id 

public 
LoadLives id 

    static 
szData256 ],  iTimestamp 
    
new szAuthid 35 
    
get_user_authid id szAuthid sizeof  szAuthid  
    
    if(  
nvault_lookupg_iVault szAuthid szDatasizeof szData -1iTimestamp ) ) 
        
LoadExistingData idszData 
    
    else 
        
NewPlayerConnected id 
    


public 
LoadExistingData id szData [256 ] ) { 
    
    static 
num ]  
    
    
strbreak szDatanumsizeof num 1szDatasizeof szData 
    
PlayerLives id ] = str_to_num num 
    


public 
NewPlayerConnected id ) { 
    
    
PlayerLivesid ] += 
    SaveLives 
id 
    


public 
SaveLives (  id  

    new 
szAuthId 35 
    
get_user_authid id szAuthId sizeof szAuthId  
    
    static 
szData256 
    
    if ( 
PlayerLivesid ] < 
        
PlayerLives id ] = 
    
    formatex
szDatasizeof  szData  -1"%i"PlayerLives id ] ); 
    
    
nvault_setg_iVaultszAuthId szData 
    
}         

public 
CmdGiveLives idlevelcid ) { 
    
    if ( ! 
cmd_access idlevelcid) ) 
        return 

    
    
new szArg1 24 ], szArg2 
    
    
read_argv 1szArg1sizeof szArg1 -1  
    
read_argv 2szArg2sizeof szArg2 -1  
    
    new 
LivesToGive str_to_num szArg2 
    
    if ( 
szArg1 ] == '@' ) { 
        
        new 
Team 
        
        
if ( equali szArg1 ], "CT" ) )  
            
Team 
        
        
else if ( equali szArg1 ], "T" ) )  
            
Team 
        
        
        
new iPlayers 32 ], iPlayersNumindex 
        
        
switch ( Team ) { 
            
            case 
1get_players iPlayersiPlayersNum"e" "TERRORIST" 
                case 
2get_players iPlayersiPlayersNum"e" "CT" 
                default: 
get_players iPlayersiPlayersNum 
            
        } 
        
        for ( new 
i=0iiPlayersNumi++ ) { 
            
            
index iPlayers 
            
PlayerLives index ] += LivesToGive   
            
        

    } 
    
    else { 
        
        new 
Target cmd_target idszArg1
        
PlayerLives Target ] += LivesToGive 
        
    

    
    
SaveLives id 
    return 

    


public 
CmdTakeLives idlevelcid ) { 
    
    if ( ! 
cmd_access idlevelcid) ) 
        return 

    
    
new szArg1 24 ], szArg2 
    
    
read_argv 1szArg1sizeof szArg1 -1  
    
read_argv 2szArg2sizeof szArg2 -1  
    
    new 
LivesToTake str_to_num szArg2 
    
    if ( 
szArg1 ] == '@' ) { 
        
        new 
Team 
        
        
if ( equali szArg1 ], "CT" ) ) 
            
Team 
        
        
else if ( equali szArg1 ], "T" ) )  
            
Team 
        
        
new iPlayers 32 ], iPlayersNumindex 
        
        
switch ( Team ) { 
            
            case 
1get_players iPlayersiPlayersNum"e" "TERRORIST" 
                case 
2get_players iPlayersiPlayersNum"e" "CT" 
                default: 
get_players iPlayersiPlayersNum 
            
        } 
        
        for ( new 
i=0iiPlayersNumi++ ) { 
            
            
index iPlayers 
            
PlayerLives index ] -= LivesToTake 
            
        

    } 
    
    else { 
        
        new 
Target cmd_target idszArg1
        
PlayerLives Target ] -= LivesToTake 
        
    

    
    
SaveLives id 
    return 

    


public 
ClCmdCheckLives id ) {
    
    
client_printidprint_chat"You have %d li%s remaining."PlayerLives id ],  PlayerLives id ] == "fe" "ves" )
    
}

public 
ClCmdLive id ) { 
    
    if ( 
is_user_alive id ) ) { 
        
        
client_print idprint_chat"You can't use this command while you are alive" 
        return 

        
    

    
    
    else { 
        
        
PlayerLives id ] -- 
        
ExecuteHamB(Ham_CS_RoundRespawnid
        
client_print idprint_chat"You just respawned" 
    } 
    
    return 

    


Last edited by HamletEagle; 07-10-2016 at 11:42.
HamletEagle is offline
jingojang
Senior Member
Join Date: Feb 2010
Location: The Moon
Old 07-30-2014 , 05:07   Re: [REQ] Give Life
Reply With Quote #15

Quote:
Originally Posted by jingojangs server
Lives 1.0 HamletEagle pg_extra_lives.amxx error
I still get no error logs or normal logs from the latest amxmodx(1.8.3).

You should test it with the same version I am using, might be some wrong with your codes or something. But it does not seem to be compatible with the 1.8.3 system from what I have seen so far.
__________________

Last edited by jingojang; 07-30-2014 at 05:07.
jingojang 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 06:35.


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