strcmp to zcmd
#1

Can anyone change this to zcmd? i already compiled it and no error. After i use it ingame nothing happens. Do you think this is because of the command processor im using?

Код:
new God[MAX_PLAYERS] = 0;

if(strcmp("/god", cmdtext, true, 10) == 0)
    {
        if (God[playerid] == 1)
        {
            GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
            SetPlayerHealth(playerid, 100);
            God[playerid] = 0;
            return 1;
        }
        else if(God[playerid] == 0)
		{
    		GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~ENABLED", 3000, 3);
    		God[playerid] = 1;
    		SetPlayerArmour(playerid, 10000);
    		SetPlayerHealth(playerid, 10000);
    		return 1;
		}
    }
Reply
#2

To operate the command
1) You must have #include zcmd
2) You must delete OnPlayerCommandText
Код:
COMMAND:godon(playerid, params[])
{
#pragma unused params
if (God[playerid] == 1)
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
SetPlayerHealth(playerid, 100);
God[playerid] = 0;
return 1;
}
else if(God[playerid] == 0)
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~ENABLED", 3000, 3);
God[playerid] = 1;
SetPlayerArmour(playerid, 10000);
SetPlayerHealth(playerid, 10000);
return 1;
}
}
Reply
#3

Quote:
Originally Posted by 404 Not Found
Посмотреть сообщение
To operate the command
1) You must have #include zcmd
2) You must delete OnPlayerCommandText
Код:
COMMAND:godon(playerid, params[])
{
#pragma unused params
if (God[playerid] == 1)
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
SetPlayerHealth(playerid, 100);
God[playerid] = 0;
return 1;
}
else if(God[playerid] == 0)
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~ENABLED", 3000, 3);
God[playerid] = 1;
SetPlayerArmour(playerid, 10000);
SetPlayerHealth(playerid, 10000);
return 1;
}
}
Still the same, nothing happens.
Reply
#4

Try
Код:
COMMAND:godon(playerid, params[])
{
#pragma unused params
if (God[playerid] == 1)
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
SetPlayerHealth(playerid, 100);
God[playerid] = 0;
return 1;
}
else
{
GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~ENABLED", 3000, 3);
God[playerid] = 1;
SetPlayerArmour(playerid, 10000);
SetPlayerHealth(playerid, 10000);
return 1;
}
}
Reply
#5

Remove the callback of OnPlayerCommandText since you won't use it and add this:

pawn Код:
CMD:god(playerid, params[])
{
    if(God[playerid])
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 0;
         return 1;
    }
    else
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 1;
         return 1;
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Randy More
Посмотреть сообщение
Remove the callback of OnPlayerCommandText since you won't use it and add this:

pawn Код:
CMD:god(playerid, params[])
{
    if(God[playerid])
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 0;
         return 1;
    }
    else
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 1;
         return 1;
    }
   return 1; <----- this line is error.
}
warning 225: unreachable code
Reply
#7

use

pawn Код:
CMD:god(playerid, params[])
{
    #pragma unused params

    // no admin check?
    if(God[playerid])
    {
         GameTextForPlayer(playerid, "~r~GOD MODE DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 0;
 
    }
    else
    {
         GameTextForPlayer(playerid, "~r~GOD MODE ENABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 1;
 
    }
    return 1;
}
Reply
#8

For sure it won't, my bad as i added twice for each status, use one above so.
Reply
#9

pawn Код:
CMD:god(playerid, params[])
{
    if(God[playerid])
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 0;
    }
    else
    {
         GameTextForPlayer(playerid, "~r~GOD ~r~MODE ~r~DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 1;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by whitetigerswt
Посмотреть сообщение
use

pawn Код:
CMD:god(playerid, params[])
{
    #pragma unused params
    if(God[playerid])
    {
         GameTextForPlayer(playerid, "~r~GOD MODE DISABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 0;
 
    }
    else
    {
         GameTextForPlayer(playerid, "~r~GOD MODE ENABLED", 3000, 3);
         SetPlayerHealth(playerid, 100);
         God[playerid] = 1;
 
    }
    return 1;
}
no error but still not working. Can you give me another script for god mode? that uses 1 command.
/god - on /god -off
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)