2 new problems
#1

i have 2 problems

1.) when i type /aduty it sets all admins to aduty here is the code

pawn Код:
CMD:admins(playerid, params[]) //credits to lamarr
{
    new string[900];
    new fstring[900];
    new adutyrank[50];
    switch(PlayerInfo[playerid][Admin])
    {
         case 1: AdminRank = "Moderator";
         case 2: AdminRank = "Global Moderator";
         case 3: AdminRank = "Administrator";
         case 4: AdminRank = "Operator";
         case 5: AdminRank = "Head Administrator";
         case 6: AdminRank = "Mapper";
         case 7: AdminRank = "Scripter";
         case 8: AdminRank = "Head Scripter";
         case 9: AdminRank = "Co-Owner";
         case 10: AdminRank = "Server-Owner";
    }
    switch(IsAdminInDuty[playerid])
    {
         case 0: adutyrank = ""red"Playing!";
         case 1: adutyrank = ""green"On Duty!";
    }
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][Admin] > 0)
        {
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(i,pname, sizeof(pname));
            format(fstring, sizeof(fstring),""white"%s (ID:%i) - "red"Level: "white"%i | %s | %s"white"\n", pname, i, PlayerInfo[i][Admin], AdminRank, adutyrank);
            strcat(string, fstring, sizeof(string));
        }
    }
    ShowPlayerDialog(playerid,2563,DIALOG_STYLE_MSGBOX,"Administrator Online",string,"OK","");
    return 1;
}
pawn Код:
CMD:aduty(playerid, params[])
{
    new string[100],pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
       if(IsAdminInDuty[playerid] == 0)
       {
           IsAdminInDuty[playerid] = 1;
           SendClientMessage(playerid, COLOR_GREEN, "You are now in Admin Duty!");
           PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
           GivePlayerWeapon(playerid, 22, 5000);
           GivePlayerWeapon(playerid, 5, 1);
           GivePlayerWeapon(playerid, 29, 5000);
           SetPlayerHealth(playerid, 999999.9);
           SetPlayerArmour(playerid, 999999.9);
           format(string, sizeof(string), "Administrator %s(ID:%d) is now on Admin Duty!", pname, playerid);
           SendClientMessageToAll(COLOR_RED, string);
       }
       else
       {
           IsAdminInDuty[playerid] = 0;
           PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
           SendClientMessage(playerid, COLOR_RED, "You are now off Duty!");
           SetPlayerHealth(playerid, 100);
           SetPlayerArmour(playerid, 100);
           format(string, sizeof(string), "Administrator %s(ID:%d) is now off Duty!", pname, playerid);
           SendClientMessageToAll(COLOR_RED, string);
       }
    }
    else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 1 or higher to use this command!");
    return 1;
}
2.) when i type /god. setplayerhealth wont work.

pawn Код:
CMD:god(playerid, params[])
{
    new string[128],pname[MAX_PLAYERS];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
        format(string, sizeof(string), "ADMIN-SPEC: %s has used /god", pname);
        SentMessageToAdmins(COLOR_GREY, string);
        if(GodMode[playerid] == 0)
        {
            GodMode[playerid] = 1;
            GodTimer = SetTimer("God", 1000, true);
            GivePlayerWeapon(playerid, 22, 5000);
            GivePlayerWeapon(playerid, 5, 1);
            GivePlayerWeapon(playerid, 29, 5000);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn on his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "| - God Mode ON! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
        else
        {
            GodMode[playerid] = 0;
            KillTimer(GodTimer);
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn off his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            SendClientMessage(playerid, COLOR_RED, "| - God Mode OFF! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
pawn Код:
forward God(playerid);
public God(playerid)
{
    SetPlayerHealth(playerid, 999999.9);
    SetPlayerArmour(playerid, 999999.9);
    return 1;
}
Please help
Reply
#2

Try with this
pawn Код:
SetPlayerHealth(playerid, 9999.9);
           SetPlayerArmour(playerid, 9999.9);
And

pawn Код:
public God(playerid)
{
    SetPlayerHealth(playerid, 9999.9);
    SetPlayerArmour(playerid, 9999.9);
    return 1;
}
If this is helpfull just +1 rep :$
Reply
#3

Stop begging pity for rep! By the way, this godmode would NOT work, 'cause if somebody would shooting at you with e.g. a minigun, your health would be fucked up in a minute! Try mine, you need to update stuff:

PHP код:
 new HasGod[MAX_PLAYERS]; 
PHP код:
    CMD:god(playeridparams[])
    {
        if(
PlayerInfo[playerid][pAdmin] >= 8)
        {
            if(
HasGod[playerid] == 0)
            {
                
HasGod[playerid] = 1;
                
SendClientMessage(playerid, -1"God mode turned on!");
            }
            else if(
HasGod[playerid] == 1)
            {
                
HasGod[playerid] = 0;
                
SendClientMessage(playerid, -1"God mode turned off!");
            }
        }
        else return 
SendClientMessage(playerid, -1"You have to be level 8 to use that command!");
        return 
1;
    } 
PHP код:
    public OnPlayerConnect(playerid) {
              
HasGod[playerid] = 0;
   return 
1;

PHP код:
    public OnPlayerUpdate(playerid)
    {
        if(
HasGod[playerid] == 1)
        {
            
SetTimer("SetHealth"100true);
        }
        return 
1;
    } 
PHP код:
    forward SetHealth(playerid);
    public 
SetHealth(playerid//this is a callback
    
{
        
SetPlayerHealth(playerid100);
        return 
1;
    } 
Simple, and not too long!
Reply
#4

Admin command:
pawn Код:
CMD:admins(playerid, params[]) //credits to lamarr
{
    new string[ 900 ];
    new fstring[ 900 ];
    new adutyrank[ 50 ];
    for( new slots = GetMaxPlayers( ), i; i < slots; i++ )
    {
        if ( !IsPlayerConnected( i ) ) continue;
        switch( PlayerInfo[ i ][ Admin ] )
        {
             case 1: AdminRank = "Moderator";
             case 2: AdminRank = "Global Moderator";
             case 3: AdminRank = "Administrator";
             case 4: AdminRank = "Operator";
             case 5: AdminRank = "Head Administrator";
             case 6: AdminRank = "Mapper";
             case 7: AdminRank = "Scripter";
             case 8: AdminRank = "Head Scripter";
             case 9: AdminRank = "Co-Owner";
             case 10: AdminRank = "Server-Owner";
        }
        switch( IsAdminInDuty[ i ] )
        {
             case 0: adutyrank = ""red"Playing!";
             case 1: adutyrank = ""green"On Duty!";
        }
        if( PlayerInfo[ i ][ Admin ] > 0 )
        {
            new pname[ MAX_PLAYER_NAME ];
            GetPlayerName( i, pname, MAX_PLAYER_NAME );
            format( fstring, 900,""white"%s (ID:%i) - "red"Level: "white"%i | %s | %s"white"\n", pname, i, PlayerInfo[ i ][ Admin ], AdminRank, adutyrank );
            strcat( string, fstring, 900 );
        }
    }
    ShowPlayerDialog( playerid, 2563, DIALOG_STYLE_MSGBOX, "Administrator Online", string, "OK", "" );
    return 1;
}
Reply
#5

one problem

/god is still like that

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GodMode[playerid] == 1)
    {
       GodTimer = SetTimer("God", 100, true);
    }
    return 1;
}


CMD:god(playerid, params[])
{
    new string[128],pname[MAX_PLAYERS];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
        format(string, sizeof(string), "ADMIN-SPEC: %s has used /god", pname);
        SentMessageToAdmins(COLOR_GREY, string);
        if(GodMode[playerid] == 0)
        {
            GodMode[playerid] = 1;
            GivePlayerWeapon(playerid, 22, 5000);
            GivePlayerWeapon(playerid, 5, 1);
            GivePlayerWeapon(playerid, 29, 5000);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn on his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "| - God Mode ON! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
        else if(GodMode[playerid] == 1)
        {
            GodMode[playerid] = 0;
            KillTimer(GodTimer);
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn off his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            SendClientMessage(playerid, COLOR_RED, "| - God Mode OFF! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
should i remove GodTimer? how about if the GM restart?
Reply
#6

anyone?
Reply
#7

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GodMode[playerid] == 1)
    {
       GodTimer = SetTimer("God", 100, true);
    }
    return 1;
}
This is going to lag you so bad. Putting a timer under OnPlayerUpdate, that has 100 miliseconds(A tenth of a second) is just crazy.

pawn Код:
CMD:god(playerid, params[])
{
    new string[128],pname[MAX_PLAYERS];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
        format(string, sizeof(string), "ADMIN-SPEC: %s has used /god", pname);
        SentMessageToAdmins(COLOR_GREY, string);
        if(GodMode[playerid] == 0)
        {
            SetPlayerHealth(playerid, 9999999);
            SetPlayerArmour(playerid, 9999999);
            GodMode[playerid] = 1;
            GivePlayerWeapon(playerid, 22, 5000);
            GivePlayerWeapon(playerid, 5, 1);
            GivePlayerWeapon(playerid, 29, 5000);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn on his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "| - God Mode ON! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
        else
        {
            GodMode[playerid] = 0;
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn off his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            SendClientMessage(playerid, COLOR_RED, "| - God Mode OFF! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
I recommend using this. If a person is shooting you with a minigun, then you might die..After a long time..Other than that your safe.
Reply
#8

try this

global var
pawn Код:
new timerid[MAX_PLAYERS];
pawn Код:
CMD:god(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, [color], "Not Authorized to use this command");

        format(string, sizeof(string), "ADMIN-SPEC: %s has used /god", pname);
        SentMessageToAdmins(COLOR_GREY, string);

        if(GodMode[playerid] == 0)
        {
            timerid[playerid] = SetTimerEx("Health", 1000, true, "d", playerid);
            GodMode[playerid] = 1;
            GivePlayerWeapon(playerid, 22, 5000);
            GivePlayerWeapon(playerid, 5, 1);
            GivePlayerWeapon(playerid, 29, 5000);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn on his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "| - God Mode ON! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
        else
        {
            GodMode[playerid] = 0;
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn off his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            SendClientMessage(playerid, COLOR_RED, "| - God Mode OFF! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
            KillTimer(timerid[playerid]);
        }

        return 1;
    }
pawn Код:
forward Health(playerid);
public Health(playerid)
{
    SetPlayerHealth(playerid, 1000);
    return 1;
}
Reply
#9

Quote:
Originally Posted by emokidx111
Посмотреть сообщение
try this

global var
pawn Код:
new timerid[MAX_PLAYERS];
pawn Код:
CMD:god(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, [color], "Not Authorized to use this command");

        format(string, sizeof(string), "ADMIN-SPEC: %s has used /god", pname);
        SentMessageToAdmins(COLOR_GREY, string);

        if(GodMode[playerid] == 0)
        {
            timerid[playerid] = SetTimerEx("Health", 1000, true, "d", playerid);
            GodMode[playerid] = 1;
            GivePlayerWeapon(playerid, 22, 5000);
            GivePlayerWeapon(playerid, 5, 1);
            GivePlayerWeapon(playerid, 29, 5000);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn on his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "| - God Mode ON! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
        }
        else
        {
            GodMode[playerid] = 0;
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            format(string, sizeof(string), "Administrator %s(ID:%d) has turn off his/her God Mode!", pname, playerid);
            SendClientMessageToAll(COLOR_RED, string);
            SendClientMessage(playerid, COLOR_RED, "| - God Mode OFF! - |");
            PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
            KillTimer(timerid[playerid]);
        }

        return 1;
    }
pawn Код:
forward Health(playerid);
public Health(playerid)
{
    SetPlayerHealth(playerid, 1000);
    return 1;
}
Thanks men it work rep+ for you
Reply
#10

Quote:
Originally Posted by L0zaix
Посмотреть сообщение
Thanks men it work rep+ for you
It might work, but it will possibly cause major lag. I would set the timer to atleast 5000(5 seconds).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)