AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] With setting gravity on user. (https://forums.alliedmods.net/showthread.php?t=236368)

Flick3rR 03-03-2014 15:09

[HELP] With setting gravity on user.
 
Hi, there, i want to ask you why doesn't this work. I've a VIPmenu where you can choise gravity, but when I make it like this:
set_user_gravity(id, 300.0)
It starts flying in air and it cant fall on the ground. I'm wondering, how can i make it like on deathrun server, or like when you type sv_gravity 300 in console and get low gravity. I'll give you the .sma to take a look on it! :) It's about the 3rd case, when i want to set the user 300 gravity by choosing option 3 on the menu.

And it looks like this (DEMO) : http://dox.bg/files/dw?a=787b241ce8
PHP Code:

public VipCTMenu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            
set_user_health(idget_user_health(id) + 30);
            
set_user_armor(idget_user_armor(id) + 30);
            
VipUsed[id] = true;
            
            
client_printc(id"%s Ti izbra !g30 Hp!n + !g30 Armor!n"PREFIX);
        }
        case 
2:
        {
            
give_item(id,"weapon_hegrenade");
            
give_item(id,"weapon_flashbang");
            
give_item(id,"weapon_flashbang");
            
give_item(id,"weapon_smokegrenade");
            
            
VipUsed[id] = true;
            
            
client_printc(id"%s Ti izbra !gVsichki Granati"PREFIX);
        }
        
         
        case 
3
        { 
            
       
set_user_gravity(id 300.0);
  
            
VipUsed[id] = true;

            
client_printc(id"%s Ti izbra !gGravity"PREFIX); 
        } 
            
              case 
4
        {
    
            
set_user_maxspeed(idfast_speed);
            
VipUsed[id] = true;
            
HasSpeed true;
            
            
client_printc(id"%s Ti izbra !gSpeed!n"PREFIX);
   } 
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

public 
VipTMenu(id)
{
    new 
menu menu_create("\yVIP Menu \r(TR):^n""VipTMenu_handler");

    
menu_additem(menu"\w30 HP + 30 Amrmor""1"0);
    
menu_additem(menu"\wAll Grenades""2"0);
    
menu_additem(menu"\wGravity""3"0);
    
menu_additem(menu"\wSpeed""4"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
VipTMenu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            
set_user_health(idget_user_health(id) + 30);
            
set_user_armor(idget_user_armor(id) + 30);
            
VipUsed[id] = true;
            
            
client_printc(id"%s Ti izbra !g30 Hp!n + !g30 Armor!n"PREFIX);
        }
        case 
2:
        {
         
give_item(id,"weapon_hegrenade");
         
give_item(id,"weapon_flashbang");
    
give_item(id,"weapon_flashbang");
         
give_item(id,"weapon_smokegrenade");
            
            
VipUsed[id] = true;
            
            
client_printc(id"%s Ti izbra !gVsichki Granati"PREFIX);
        }
        
         
        case 
3
        { 
               
            
set_user_gravity(id300);
  
            
VipUsed[id] = true

            
client_printc(id"%s Ti izbra !gGravity"PREFIX); 
        } 
            
              case 
4
        {
    
            
set_user_maxspeed(idfast_speed);
            
VipUsed[id] = true;
            
HasSpeed true;
            
            
client_printc(id"%s Ti izbra !gSpeed!n"PREFIX);
   } 
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Sorry for my english!

minato 03-03-2014 15:20

Re: [HELP] With setting gravity on user.
 
PHP Code:

set_user_gravity(index0.3


YamiKaitou 03-03-2014 15:23

Re: [HELP] With setting gravity on user.
 
set_user_gravity works differently than sv_gravity. Setting it to 1 will make the user's gravity the same as the server. Setting it less than 1 makes it less than the server and greater than 1 makes it higher than the server

Flick3rR 03-03-2014 16:06

Re: [HELP] With setting gravity on user.
 
That's what is happening - http://prikachi.com/images.php?images/129/7123129H.jpg
Errors, again and again. I don't know what to do, i tried to set it on 0.3, 0.64, and many other numbers, but the same thing happens in the server.
PHP Code:

set_user_gravity(id0.63)
set_user_gravity(id0.33)
set_user_gravity(id0.2)
set_user_gravity(id0.80

They all don't work. Plese, help!

mapper07 03-03-2014 17:14

Re: [HELP] With setting gravity on user.
 
change index to id

Flick3rR 03-04-2014 03:39

Re: [HELP] With setting gravity on user.
 
Look to the upper post, with index or id, it doesn't work. I'm flyung up and down in the server again and this is weird. Maybe I need to add something else in the .sma to fix it?

georgik57 03-04-2014 03:47

Re: [HELP] With setting gravity on user.
 
Code:
const Float:fPlayerGravity = 300.0 set_user_gravity(id, fPlayerGravity / 800)

NiHiLaNTh 03-04-2014 04:06

Re: [HELP] With setting gravity on user.
 
it should be vice-versa
cause 300 means that player ir lighter than normally (800), but with your code it would be heavier, so it must be then 300.0 / 800.0

georgik57 03-04-2014 04:37

Re: [HELP] With setting gravity on user.
 
Quote:

Originally Posted by NiHiLaNTh (Post 2107189)
it should be vice-versa
cause 300 means that player ir lighter than normally (800), but with your code it would be heavier, so it must be then 300.0 / 800.0

Corrected.

Flick3rR 03-04-2014 15:58

Re: [HELP] With setting gravity on user.
 
Thank you, Georgik57!!!! This worked, thank you so much!
Now i want to ask, why when I set some speed to user, it's like the maximum fast, and the number of the speed doesnt matter, it's everytime that fast. I want to ask, how am I supposed to set_user speed, just little over the normal. Like if the normal is 250, i want to set the user speed 300. Perhaps it's again something with new float, but i'll be so grateful if someone tell me what to do. :)


All times are GMT -4. The time now is 05:57.

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