Raised This Month: $ Target: $400
 0% 

Need help to code ladder in to blockmaker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
znovit
Member
Join Date: Mar 2009
Location: Behind you :=
Old 06-07-2009 , 05:28   Re: Need help to code ladder in to blockmaker
Reply With Quote #1

Here ya go

PHP Code:
#include <amxmodx> 
#include <fakemeta_util> 

#pragma semicolon 1 

#define MODEL "models/ladder.mdl" 

// ladder dimensions 
new Float:gLadderMinY[3] = {-32.0,-4.0,-32.0}; 
new 
Float:gLadderMaxY[3] = { 32.04.032.0}; 

new 
bool:gOnLadder[33]; 

public 
plugin_init() { 
    
register_plugin("Ladder""1.0""xPaw"); 
     
    
register_clcmd("say .ladder""cmdCreateLadder"); 
    
register_clcmd("say .removeladder""cmdDeleteLadder"); 
     
    
register_forwardFM_PlayerPreThink"fwdPlayerPreThink"); 
    
register_forwardFM_Touch"fwdTouch" ); 


public 
plugin_precache() 
    
precache_modelMODEL ); 

public 
fwdPlayerPreThink(id) { 
    if ( 
is_user_alive(id)) { 
        if( 
gOnLadder[id] ) { 
            new 
Float:velocity[3]; 
            
pev(idpev_velocityvelocity); 
             
            if ( (
pev(idpev_button) & IN_FORWARD) && (velocity[0] == 0.0 || velocity[1] == 0.0) ) { 
                
velocity[2] = 250.0
                
set_pev(idpev_velocityvelocity); 
            } 
            
gOnLadder[id] = false
        } 
         
        new 
entbody
        
get_user_aiming(identbody320); 
         
        if (
isLadder(ent)) { 
            
set_hudmessage(025255, -1.0, -0.9001.01.00.20.21); 
            
show_hudmessage(id"First In-Game Ladder."); 
        } 
    } 


public 
fwdTouch(entid) { 
    if (
is_user_alive(id) && isLadder(ent)) { 
        
set_pev(idpev_movetypeMOVETYPE_FLY); 
         
        
gOnLadder[id] = true
         
        
// Velocity way 
        
new Float:velocity[3]; 
        
pev(idpev_velocityvelocity); 
         
        if ( (
pev(idpev_button) & IN_FORWARD) && (velocity[0] == 0.0 || velocity[1] == 0.0) ) { 
            
velocity[2] = 250.0
            
set_pev(idpev_velocityvelocity); 
        } 
         
    } 


public 
cmdCreateLadderid ) { 
    if (
get_user_flags(id) & ADMIN_KICK) { 
        new 
Float:vOrigin[3]; 
        new 
origin[3]; 
         
        
//get the origin of the player and add Z offset 
        
get_user_origin(idorigin3); 
        
IVecFVec(originvOrigin); 
        
vOrigin[2] += 4.0
         
        
createLaddervOrigin ); 
        
client_print(idprint_chat"* You Spawned Ladder, Have Fun! :-)"); 
    } 


public 
cmdDeleteLadder(id) { 
    if (
get_user_flags(id) & ADMIN_KICK) { 
        new 
entbody
        
get_user_aiming(identbody); 
         
        if (
isLadder(ent)) { 
            
fm_remove_entity(ent); 
            
client_print(idprint_chat"* You Removed Ladder."); 
        } 
    } 


createLadderFloat:vOrigin[3] ) { 
    new 
ent fm_create_entity"info_target" ); 
     
    if (
fm_is_valid_ent(ent)) { 
        
set_pev(entpev_classname"xpaw_ladder"); 
        
set_pev(entpev_solidSOLID_BBOX); 
        
set_pev(entpev_movetypeMOVETYPE_NONE); 
         
        new 
Float:vSizeMin[3]; 
        new 
Float:vSizeMax[3]; 
        new 
Float:vAngles[3]; 

        
vSizeMin gLadderMinY
        
vSizeMax gLadderMaxY
        
vAngles[0] = 90.0
        
vAngles[2] = 90.0
         
        
//adjust size min/max vectors depending on scale 
        
for (new 03; ++i) { 
            if (
vSizeMin[i] != 4.0 && vSizeMin[i] != -4.0
                
vSizeMin[i] *= 1.0
             
            if (
vSizeMax[i] != 4.0 && vSizeMax[i] != -4.0
                
vSizeMax[i] *= 1.0
        } 
         
        
fm_entity_set_model(entMODEL); 
        
set_pev(entpev_anglesvAngles); 
        
fm_entity_set_size(entvSizeMinvSizeMax); 
        
fm_entity_set_origin(entvOrigin); 
         
        return 
ent
    } 
     
    return 
0


bool:isLadder(ent) { 
    if (
fm_is_valid_ent(ent)) { 
        new 
szClassname[32]; 
        
pev(entpev_classnameszClassname32); 
         
        if (
equal(szClassname"xpaw_ladder")) 
            return 
true
    } 
    return 
false

Attached Files
File Type: zip ladder_model.zip (1.6 KB, 198 views)
__________________
znovit 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 23:35.


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