/calm and /uncalm
#1

Hi, I need this two commands /calm to calm the server for one minute. In that time no player can use weapons. And /uncalm to finish the quite time and the players can use weapons. Thank you and please USE strcmp.
Reply
#2

Why strcmp?

pawn Код:
new bool:pvp;
pawn Код:
CMD:pvp(playerid)
{
    if(pvp == true)
    {
        pvp = false;
        SendClientMessageToAll(-1,"PVP Disabled!");
    }
    else
    {
        pvp = true;
        SendClientMessageToAll(-1,"PVP Enabled! Go kill everybody");
    }
    return 1;
}
;

This could help you...
Reply
#3

Hi, here try this...

pawn Код:
//on top of you GM
new Calm;
forward UnsetCalm();
forward GunTimer();
// on game mode init
    SetTimer("GunTimer", 5000, 1); // checking every 5 seconds for weapons on server
// ===========

if (strcmp(cmd, "/calm", true) == 0)
{
        if(IsPlayerConnected(playerid))
    {
        calm= 1;
            SetTimer("UnsetCalm",60000,false);
            }
        return 1;
    }
if (strcmp(cmd, "/uncalm", true) == 0)
{
     if(IsPlayerConnected(playerid))
     {
          // write here whatever you want
          calm= 0;
          KillTimer(UnsetCalm);
     }
     return 1;
}

public UnsetCalm()
{
    calm= 0;
    return 1;
}
public GunTimer()
{
    foreach (Player, i)
    {
        if(calm = 1)
        {
            for (new g=0; g<9; g++)
                {
                      new sweapon, sammo;
              GetPlayerWeaponData(i, g, sweapon, sammo);
                  if(sweapon != 0 && sammo != 0)
                  {
                    ResetPlayerWeapons(i);
                    GameTextForPlayer(i, "~w~Server is in~n~~r~peace mode!!!", 5000, 1);
              }
            }
        }
    }
    return 1;
}
Reply
#4

This is sort of off-topic, but I seriously don't understand why people still insist on having strcmp as their command processor. You're commands are going to execute slower than dirt this way, and you aren't doing yourself any favors. Continuing to use strcmp as your command processor is like running 10 infinite loops in the background on the original Godfather script!
Reply
#5

RealCop, leave him if that's the way he wants
P.S. I also prefer ZCMD but maybe he doesn't know how to convert STRCMP to ZCMD, you never know
Reply
#6

Quote:
Originally Posted by Sime30
Посмотреть сообщение
RealCop, leave him if that's the way he wants
P.S. I also prefer ZCMD but maybe he doesn't know how to convert STRCMP to ZCMD, you never know
I'm not stabbing him in the throat repeatedly. I'm just making a valid statement.
Reply
#7

I prefer to use SetPlayerTeam, while server is on the calm state with new function anit-vehicle killing for team mates. However, you can set player healths to god value or check in GlobalTimer every second or in OnPlayerUpdate is player weapon is different than "0", which means FISTS.
Reply
#8

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I prefer to use SetPlayerTeam, while server is on the calm state with new function anit-vehicle killing for team mates. However, you can set player healths to god value or check in GlobalTimer every second or in OnPlayerUpdate is player weapon is different than "0", which means FISTS.
I agree with you, but I think that the code I gave him will work. Didn't test it yet but I believe it will work.
Reply
#9

I'll go on topic for a second...

Use a bool statement to determine if the server state is calm or not.

Under OnPlayerUpdate (I know people say not to use it, but it's fine for this.), add this:

pawn Код:
if(calmState == true) SetPlayerArmedWeapon(playerid, 0);
That will check if someone tries to scroll a different weapon. If they do, it resets it back to their fist.
Reply
#10

Quote:
Originally Posted by Sime30
Посмотреть сообщение
Hi, here try this...

pawn Код:
//on top of you GM
new Calm;
forward UnsetCalm();
forward GunTimer();
// on game mode init
    SetTimer("GunTimer", 5000, 1); // checking every 5 seconds for weapons on server
// ===========

if (strcmp(cmd, "/calm", true) == 0)
{
        if(IsPlayerConnected(playerid))
    {
        calm= 1;
            SetTimer("UnsetCalm",60000,false);
            }
        return 1;
    }
if (strcmp(cmd, "/uncalm", true) == 0)
{
     if(IsPlayerConnected(playerid))
     {
          // write here whatever you want
          calm= 0;
          KillTimer(UnsetCalm);
     }
     return 1;
}

public UnsetCalm()
{
    calm= 0;
    return 1;
}
public GunTimer()
{
    foreach (Player, i)
    {
        if(calm = 1)
        {
            for (new g=0; g<9; g++)
                {
                      new sweapon, sammo;
              GetPlayerWeaponData(i, g, sweapon, sammo);
                  if(sweapon != 0 && sammo != 0)
                  {
                    ResetPlayerWeapons(i);
                    GameTextForPlayer(i, "~w~Server is in~n~~r~peace mode!!!", 5000, 1);
              }
            }
        }
    }
    return 1;
}
Look bor I got errors
Код:
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1009) : error 017: undefined symbol "cmd"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1013) : error 017: undefined symbol "calm"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1013) : warning 215: expression has no effect
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1019) : error 017: undefined symbol "cmd"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1024) : error 017: undefined symbol "calm"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1024) : warning 215: expression has no effect
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1025) : error 076: syntax error in the expression, or invalid function call
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1030) : error 029: invalid expression, assumed zero
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1030) : error 004: function "UnsetCalm" is not implemented
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1032) : error 017: undefined symbol "calm"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1032) : warning 215: expression has no effect
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1035) : warning 225: unreachable code
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1035) : error 029: invalid expression, assumed zero
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1035) : error 004: function "GunTimer" is not implemented
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1037) : error 017: undefined symbol "foreach"
C:\WINDOWS\security\kidn\Server\xgamemodes\DM.pwn(1039) : error 017: undefined symbol "calm"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1039) : warning 215: expression has no effect
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1039) : error 001: expected token: ";", but found ")"
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1039) : error 029: invalid expression, assumed zero
C:\WINDOWS\security\kidn\Server\x\gamemodes\DM.pwn(1039) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

15 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)