[Tutorial] Setting GodMode to a player ! [Unique]
#1

Setting GodMode to a player :

[UNIQUE]



• Hello, I was bored, so I decided to make a /SetGodMode command tutorial.

• What is this?
• Answer: It's a command, wich will sets to a player GodMode [Infinity Life]

• I think this command it's unique, because I never seen this before.


Starting :

pawn Код:
CMD:setgodmode(playerid,params[]) // This it's our command made with ZCMD ;
                                  // ZCMD = A command processor made by Zeex [Thanks Zeex]
{ // We open brackelet !
    new ID; // Making a Variable for ID. Wich represent the PlayerID of that player !
    if(IsPlayerAdmin(playerid)) // This it's the Admin Variable. This is a variable for RCON Admin ;
                                // So you need first to log in as RCON, before using this command.
                                // Or change with your Admin Variable.
    { // Open second brackelet, before your admin variable !
        if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]"); // If he makes something wrong, only /SetGodMode, will show to him Usage.
        SetPlayerHealth(ID, 10000000); // Will sets to specified player GodMode. [100000000 Life]
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !"); // This will saw the Admin wich gonna sets GodMode to a player !
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !"); // This will saw player, wich Admin sets to it God Mode
    } // Closing brackelet !
    else // Else, if he use that command again on that player, will sets 100 life !
    { // Open brackelet
        SetPlayerHealth(ID, 100); // Will sets to that player 100 life, for second use.
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); // This will saw the Admin wich writes second time /SetGodMode [ID]
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); // This will saw the player !
    }
    return 1; // We need to return 1, else we will get errors.
} // And we close the last brackelet.

/*

After you did this, your command will works.
It's a simple command, but unique.

*/

All code :

pawn Код:
#include <a_samp>
#include <zcmd>

CMD:setgodmode(playerid,params[])
{
    new ID;
    if(PlayerInfo[playerid][Admin] >= 2)
    {
        if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]");
        SetPlayerHealth(ID, 10000000);
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !");
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !");
    }
    else
    {
        SetPlayerHealth(ID, 100);
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
    }  
    return 1;
}
Before start, you need to have ZCMD include, by Zeex. If you don't have, download it from right here !
Reply
#2

Really nice.
Reply
#3

Well done.
Reply
#4

It's bracket, not brackelet

pawn Код:
else // Else, if he use that command again on that player, will sets 100 life !
    { // Open brackelet
        SetPlayerHealth(ID, 100); // Will sets to that player 100 life, for second use.
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); // This will saw the Admin wich writes second time /SetGodMode [ID]
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); // This will saw the player !
    return 1; // We need to return 1, else we will get errors.
} //
And you forgot a bracket here. (before return 1)

pawn Код:
else
    {
        SetPlayerHealth(ID, 100);
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command !");
    }
And you can't write an 'else' twice...
The code has lots of errors, it wont work..


Besides that, good job to trying to write a tutorial !
Reply
#5

Woah, nice, good job.
Reply
#6

What is so unique about it?
Reply
#7

Quote:
Originally Posted by Stuun
Посмотреть сообщение
Really nice.
Quote:
Originally Posted by Flori
Посмотреть сообщение
Well done.
Thanks.

Quote:
Originally Posted by Sasino97
Посмотреть сообщение
It's bracket, not brackelet

pawn Код:
else // Else, if he use that command again on that player, will sets 100 life !
    { // Open brackelet
        SetPlayerHealth(ID, 100); // Will sets to that player 100 life, for second use.
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!"); // This will saw the Admin wich writes second time /SetGodMode [ID]
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !"); // This will saw the player !
    return 1; // We need to return 1, else we will get errors.
} //
And you forgot a bracket here. (before return 1)

pawn Код:
else
    {
        SetPlayerHealth(ID, 100);
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
        SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command !");
    }
And you can't write an 'else' twice...
The code has lots of errors, it wont work..


Besides that, good job to trying to write a tutorial !
Thanks, solved.

Quote:
Originally Posted by Arastair
Посмотреть сообщение
Woah, nice, good job.
Thanks !

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
What is so unique about it?
Nobody did this? It's first time. Did somebody else made a "/SetGodMode" command? I want to see a post like this !
Reply
#8

I found look http://forum.sa-mp.com/showthread.ph...17#post3252417
Reply
#9

It would be better if you could add a command to change a group of players gamemodes
Reply
#10

Код:

// LOGICALLY INCORRECT CODE

#include <a_samp>
#include <zcmd>


CMD:setgodmode(playerid,params[])
{
	new ID;
	if(PlayerInfo[playerid][Admin] >= 2)
	{
    	if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]");
    	SetPlayerHealth(ID, 10000000);
    	SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !");
    	SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !");
	}
	else
	{
        SetPlayerHealth(ID, 100);
    	SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
    	SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
        }
    }	
    return 1;
}
That's still not working as it is supposed to do...

the keyword else means what it should do if the if condition is false. So basically, you are telling it:
IF playerid is admin
SET ID's Health to 1000000
IF playerid is not admin
SET ID's Health to 100

To make it working good you should tell it to

IF playerid is admin and ID has normal health
SET ID's Health to 1000000
IF playerid is admin and ID has god mode
SET ID's Health to 100
IF playerid is not admin
TELL playerid that he can't use that command

GOOD CODE
pawn Код:
CMD:setgodmode(playerid,params[])
{
    // outside
    new godmode[MAX_PLAYERS];

    //inside the CMD:
    new ID;
    if(PlayerInfo[playerid][Admin] >= 2)
    {
        if(sscanf(params,"i", ID)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/SetGodMode [PlayerID]");
       
        if(godmode[playerid] == 0)
        {
            godmode[playerid] = 1;
            SetPlayerHealth(ID, 10000000);
            SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave Infinity Life {FFFF00}[GODMODE] {15FF00}to specified player !");
            SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You received Infinity Life {FFFF00}[GODMODE] {15FF00}from Administrator !");
        }
        else
        {
            godmode[playerid] = 0;
            SetPlayerHealth(ID, 100);
            SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You player's Infinity Life {FFFF00}[GODMODE] [15FF00}!");
            SendClientMessage(ID, -1, "{FF0000}AdmCmd: {15FF00}You don't have GodMode now !");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}You're not authorized to use this command{15FF00}!");
    }  
    return 1;
}
I have to say something on this too:
pawn Код:
if(PlayerInfo[playerid][Admin] >= 2)
This is not standard, you have to explain the readers that PlayerInfo[playerid][Admin] could not be the same on all scripts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)