SA-MP Forums Archive
strcmp to zcmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strcmp to zcmd (/showthread.php?tid=354259)



strcmp to zcmd - kbalor - 26.06.2012

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;
		}
    }



Re: strcmp to zcmd - 404 Not Found - 26.06.2012

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;
}
}



Re: strcmp to zcmd - kbalor - 26.06.2012

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.


Re: strcmp to zcmd - 404 Not Found - 26.06.2012

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;
}
}



Re: strcmp to zcmd - Randy More - 26.06.2012

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;
}



Re: strcmp to zcmd - kbalor - 26.06.2012

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


Re: strcmp to zcmd - Whitetiger - 26.06.2012

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;
}



Re: strcmp to zcmd - Randy More - 26.06.2012

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


Re: strcmp to zcmd - Skaizo - 26.06.2012

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;
}



Re: strcmp to zcmd - kbalor - 26.06.2012

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