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

Comment faire voler un joueur


  
 
 
Thread Tools Display Modes
Author Message
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 01-04-2011 , 08:00   Comment faire voler un joueur
#1

Bonjour

J'essaie actuellement de permettre aux joueurs de voler dans le ciel.
J'ai déjà fais pas mal de recherches et de test et j'ai fini par trouver ce code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <cstrike>

#define NOCLIP_SPEED 900.0

new bool:g_flying[33];

public 
plugin_init()
    {
    
register_plugin("Noclip Simulator""0.1""Exolent");
    
    
register_clcmd("say /fly""CmdFly");
    
    
register_forward(FM_PlayerPreThink"FwdPlayerPreThink");
}

public 
client_disconnect(client)
    {
    
g_flying[client] = false;
}

public 
CmdFly(client)
    {
    
g_flying[client] = !g_flying[client];
    
    
client_print(clientprint_chat"You are no%s flying."g_flying[client] ? "w" " longer");
    
    
set_pev(clientpev_gravityg_flying[client] ? 0.000001 1.0);
    
    return 
PLUGIN_HANDLED;
}

public 
FwdPlayerPreThink(client)
{
    if( !
g_flying[client] || !is_user_alive(client) ) return;
    
    
set_pev(clientpev_movetypeMOVETYPE_FLY);
    
    new 
Float:maxspeed NOCLIP_SPEED;
    if( 
is_user_ducking(client) )
        {
        
// I don't know the real calculation for ducking velocity
        // but this will have to do for now
        
maxspeed /= 2.0;
    }
    
    static 
Float:aim_velocity[3];
    
velocity_by_aim(clientfloatround(maxspeed), aim_velocity);
    
    static 
Float:client_origin[3];
    
pev(clientpev_originclient_origin);
    
    new 
button pev(clientpev_button);
    
    new 
Float:velocity[3];
    if( 
button IN_FORWARD )
        {
        
velocity[0] += aim_velocity[0];
        
velocity[1] += aim_velocity[1];
        
velocity[2] += aim_velocity[2];
    }
    if( 
button IN_BACK )
        {
        
velocity[0] -= aim_velocity[0];
        
velocity[1] -= aim_velocity[1];
        
velocity[2] -= aim_velocity[2];
    }
    if( 
button IN_MOVERIGHT )
        {
        
// angle velocity_aim -90 degrees
        
        //velocity[0] += ((floatcos(-90.0, degrees) * velocity_aim[0]) - (floatsin(-90.0, degrees) * velocity_aim[1]));
        //                 cos 90 = 0                                     sin -90 = -1
        //               (( 0 * velocity_aim[0] ) - ( -1 * velocity_aim[1] ))
        //               velocity_aim[1]
        
velocity[0] += aim_velocity[1];
        
        
//velocity[1] += ((floatsin(-90.0, degrees) * velocity_aim[0]) - (floatcos(-90.0, degrees) * velocity_aim[1]));
        //                sin -90 = -1                                      cos -90 = 0
        //               (( -1 * velocity_aim[0] ) - ( 0 * velocity_aim[1] ))
        //               -velocity_aim[0]
        
velocity[1] -= aim_velocity[0];
    }
    if( 
button IN_MOVELEFT )
        {
        
// angle velocity_aim 90 degrees
        
        //velocity[0] += ((floatcos(90.0, degrees) * velocity_aim[0]) - (floatsin(90.0, degrees) * velocity_aim[1]));
        //               cos 90 = 0                                      sin 90 = 1
        //               (( 0 * velocity_aim[0] ) - ( 1 * velocity_aim[1] ))
        //               -velocity_aim[1]
        
velocity[0] -= aim_velocity[1];
        
        
//velocity[1] += ((floatsin(90.0, degrees) * velocity_aim[0]) - (floatcos(90.0, degrees) * velocity_aim[1]));
        //               sin 90 = 1                                      cos 90 = 0
        //               (( 1 * velocity_aim[0] ) - ( 0 * velocity_aim[1] ))
        //               velocity_aim[0]
        
velocity[1] += aim_velocity[0];
    }
    
    
set_pev(clientpev_velocityvelocity);
}

// modified from kz_ljs_xm
bool:is_user_ducking(client)
{
    static 
Float:absmin[3], Float:absmax[3];
    
pev(clientpev_absminabsmin);
    
pev(clientpev_absmaxabsmax);
    
    return ( (
absmax[2] - absmin[2]) > 64.0 );

Le problème est qu'il est bancal.
Il fait affreusement lag le serveur
Et quand deux joueurs qui volent se touchent, les pings montent directement à 500/600

J'ai compris la base du code, je cherche un moyen de diminuer les lags.

Merci d'avance
__________________
PsYChOPaTiQuE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2011 , 11:08   Re: Comment faire voler un joueur
#2

Un bon coup de pied bien placé et ça devrait fonctionner.
Sinon essaie pev_movetype MOVETYPE_FLY
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Golradir
Senior Member
Join Date: Nov 2010
Old 01-04-2011 , 15:00   Re: Comment faire voler un joueur
#3

J'ai un plugin vole sans bindage si ca t'interesse
Golradir is offline
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 01-04-2011 , 15:07   Re: Comment faire voler un joueur
#4

Je veux bien ;)

Et connor, c'est déjà mis dans le code
__________________
PsYChOPaTiQuE is offline
Golradir
Senior Member
Join Date: Nov 2010
Old 01-04-2011 , 16:49   Re: Comment faire voler un joueur
#5

Mais ya un soucis dessus, c'est que tu commence a bouger qu'en le decompte commence, et tu peut pas t'arreter sauf en sautant une fois ...

Golradir is offline
PsYChOPaTiQuE
Veteran Member
Join Date: Jan 2009
Location: Paris
Old 01-04-2011 , 16:52   Re: Comment faire voler un joueur
#6

c'est bon je prendrai ce qui me sert dans le plugin ;)
__________________
PsYChOPaTiQuE is offline
Msieur_chat
Junior Member
Join Date: Dec 2011
Old 12-23-2011 , 16:57   Re: Comment faire voler un joueur
#7

Pour faire voulez les joueur tu peut utiliser le grab ou le slap




Si sa peut te servir .
Msieur_chat is offline
Kidev
Veteran Member
Join Date: Jun 2010
Location: France
Old 12-23-2011 , 17:08   Re: Comment faire voler un joueur
#8

Tu peux arrêter de up des messages pour rien?
__________________
Kidev is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-23-2011 , 18:58   Re: Comment faire voler un joueur
#9

Surtout que ces solutions, psychopate les connais sûrement, et ce n'est pas ça qu'il désire.

@Msieur chat: Essaye de comprendre ce que souhaite l'auteur avant d'y répondre.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Msieur_chat
Junior Member
Join Date: Dec 2011
Old 12-24-2011 , 13:52   Re: Comment faire voler un joueur
#10

Ok Devil259 ^^
Msieur_chat is offline
 



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 13:18.


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