Setting Gravity With Gforces
#1

Hey again,

I made a command that will set the gravity to G Forces (1G = 0.008 gravity). But it bugs in a way I can't explain.
PHP код:
COMMAND:setgravity(playeridparams[])
{
    new 
GForce;
    if(
level[playerid] >= 4)
    {
        if(
sscanf(params"f"GForce)) return SendClientMessage(playeridCOLOR_RED"Usage: /setgravity [50 to -50]");
        else if(
GForce 50 || GForce < -50)
        {
              {
                new 
Float:Gravity;
                
Gravity floatmul(0.008GForce);
                
SetGravity(Gravity);
             }
           }
        else return 
SendClientMessage(playeridCOLOR_RED"ERROR : Gravity cant be above 50 or under -50!");
    }
    else return 
SendClientMessage(playeridCOLOR_RED"ERROR : You have to be Administrator level 4 to use this command!");
    return 
1;

I need help with fixing or re-making this. I basically want a command that sets the gravity to G Forces. So "/setgravity 2" will set it to 0.016. Can anyone help me with this?

Ps. I also need to be able to use decimal numbers in the command ("/setgravity 0.5")...
Reply
#2

Try this

Код:
COMMAND:setgravity(playerid, params[])
{
	new gravity;
    if(level[playerid] >= 4)
    {
        if(sscanf(params, "d", gravity)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setgravity [50 to -50]");
        else if(gravity > 50 || gravity < -50)
        {
              {
                SetGravity(gravity*0.008);
                SendClientMessage(playerid, COLOR_GREEN, "Gravity has been changed");
             }
           }
        else return SendClientMessage(playerid, COLOR_RED, "ERROR : Gravity cant be above 50 or under -50!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR : You have to be Administrator level 4 to use this command!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)