AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Doing ladder (https://forums.alliedmods.net/showthread.php?t=82064)

xPaw 12-16-2008 14:54

Doing ladder
 
yes i saw many theards about it.. but i think i found a way how to do it

My idea is spawn info_null, and give mins/maxs, and give him classname or something, then check if player touching it - set velocity[2] to 250.0 :) (ah yea check the player pressing moving keys or no ? then add sounds and so on, also spawn at same place the model or skin or something else)

Have fun! 2morrow i will try todo something too :)

xPaw 12-18-2008 07:18

Re: Doing ladder
 
1 Attachment(s)
omg! :o i did it climbable, kinda weird, but i can climb on it + hear the ladder sounds!
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;



SnoW 12-18-2008 08:49

Re: Doing ladder
 
I quess you can't never make a perfect ladder. Because you don't do it same way it's done in maps, it's not possible.

xPaw 12-18-2008 09:17

Re: Doing ladder
 
yes, but its a progress so i did it climbable anyway oO

ConnorMcLeod 12-18-2008 10:27

Re: Doing ladder
 
1 Attachment(s)
My attempt is not perfect (yet ?), i don't manage to stay with 0 velocity and also my velocity calculation is not perfect (yet ?).
I will need a model if i manage to code this better.

minimiller 12-18-2008 11:19

Re: Doing ladder
 
Good job xPaw!
:up:

Exolent[jNr] 12-18-2008 11:34

Re: Doing ladder
 
I have a good idea on how to get the velocity right, just let me get on my other computer in about 15 minutes.

xPaw 12-18-2008 11:37

Re: Doing ladder
 
oke :) lets do LadderMaker, when do ladder perfect :D

Exolent[jNr] 12-18-2008 12:23

Re: Doing ladder
 
Here is my idea for simulating the ladder movement.
I didn't add the ladder making to it cause I got lazy.

xPaw 12-18-2008 12:34

Re: Doing ladder
 
1 Attachment(s)
Exolent watch demo of your plugin work :D

P.S. Download model.


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

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