SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/06/2012, 11:21 PM   #1
Kurtis96z
Little Clucker
 
Join Date: May 2012
Posts: 18
Reputation: 0
Default Godmode Command Help[ZCMD][SOLVED]

I am really new to this and what I am trying to make here is a toggle-able command. Basically what I want it to do is make it set there health extremely high (godmode on) and then if they typed the command again, it will set the players health back to normal. Can someone help me?

Quote:
CMD:godmode(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if (health == 100)
{
SetPlayerHealth(playerid, 90000.0);
SendClientMessageToAll(0xFFFF00AA, "A player has enabled godmode!");
}
else if(health == 90000.0 )
{
SetPlayerHealth(playerid, 100.0);
SendClientMessageToAll(0xFFFF00AA, "A player has disabled godmode!");
}
return 1;
}

Last edited by Kurtis96z; 03/06/2012 at 12:19 AM. Reason: SOLVED
Kurtis96z is offline   Reply With Quote
Old 02/06/2012, 11:25 PM   #2
BleverCastard
Gangsta
 
Join Date: Dec 2011
Posts: 845
Reputation: 43
Default Re: Godmode Command Help[ZCMD]

pawn Code:
CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0)
    {
        SetPlayerHealth(playerid, HEALTHHERE);
    }
    else if(GodMode[playerid] == 1)
    {
        SetPlayerHealth(playerid, HEALTHHERE);
    }
    return 1;
}

add
Code:
new GodMode[MAX_PLAYERS];
to the top of your script.

NOT TESTED.

EDIT: Your's is kinda wrong, but I like your thinking

EDIT2: Also, under OnPlayerConnect add this;
Code:
GodMode[playerid] = 0;
__________________
Quote:
Originally Posted by Mauzen View Post
You earned 8000 euros by luring credulous people into your gingerbread house of paid-click reflinks?
BleverCastard is offline   Reply With Quote
Old 02/06/2012, 11:29 PM   #3
Kurtis96z
Little Clucker
 
Join Date: May 2012
Posts: 18
Reputation: 0
Default Re: Godmode Command Help[ZCMD]

Yeah, the terminology of when things are executing on mine are EXTREMELY exact, I plan to change that after I see it is working.

EDIT: just tried what Ditch suggested and it didn't work - Godmode turned on, but it would not turn off.
Kurtis96z is offline   Reply With Quote
Old 02/06/2012, 11:52 PM   #4
Jonny5
Gangsta
 
Join Date: Mar 2012
Location: Mi, USA
Posts: 929
Reputation: 158
Default Re: Godmode Command Help[ZCMD]

pawn Code:
#define INFINITY                (Float:0x7F800000)
new GodMode[MAX_PLAYERS];



CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0) //god mode not set, lets set it
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
        GodMode[playerid] = 1;    //set godmode to true
    }
    else if(GodMode[playerid] == 1) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
        GodMode[playerid] = 0;    //set godmode to false
    }
    return 1;
}

this is kinda how i do it.

but without extra vars like this

pawn Code:
#define INFINITY                (Float:0x7F800000)
CMD:godmode(playerid, params[])
{
    new Float:health;
    GetPlayerHealth(playerid, health);
    if(health > 100.0) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
    }
    else //god mode not set, lets set it  
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
    }
    return 1;
}
__________________
If your topic says "REP+", I ignore it.
Jonny5 is offline   Reply With Quote
Old 02/06/2012, 11:57 PM   #5
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,850
Reputation: 675
Default AW: Godmode Command Help[ZCMD]

Why did you post once in Script Request Thread and here ?

Also just some little edits and done
pawn Code:
CMD:godmode(playerid) {
    new
        Float: health
    ;
    GetPlayerHealth(playerid, health);

    if(health <= 100.0) {
        SetPlayerHealth(playerid, Float: 0x7F800000);
        SendClientMessageToAll(0xFFFF00FF, "A player has enabled godmode!");
    } else {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessageToAll(0xFFFF00FF, "A player has disabled godmode!");
    }
    return true;
}
Nero_3D is offline   Reply With Quote
Old 03/06/2012, 12:00 AM   #6
Kurtis96z
Little Clucker
 
Join Date: May 2012
Posts: 18
Reputation: 0
Default Re: Godmode Command Help[ZCMD]

Awesome, Jonny that worked.

Any idea how I could modify what ive done so that my global messages saying a player is using godmode/isnt using godmode can be changed to display the actual players name instead of just the word player?

Quote:
Originally Posted by Nero_3D View Post
Why did you post once in Script Request Thread and here ?

Also just some little edits and done
pawn Code:
CMD:godmode(playerid) {
    new
        Float: health
    ;
    GetPlayerHealth(playerid, health);

    if(health <= 100.0) {
        SetPlayerHealth(playerid, Float: 0x7F800000);
        SendClientMessageToAll(0xFFFF00FF, "A player has enabled godmode!");
    } else {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessageToAll(0xFFFF00FF, "A player has disabled godmode!");
    }
    return true;
}
Sorry, I'll delete my post there :C
Kurtis96z is offline   Reply With Quote
Old 03/06/2012, 12:04 AM   #7
Edward156
Big Clucker
 
Edward156's Avatar
 
Join Date: May 2012
Location: Doing everything for the glory of God.
Posts: 98
Reputation: 9
Default Re: Godmode Command Help[ZCMD]

Quote:
Originally Posted by Kurtis96z View Post
Awesome, Jonny that worked.

Any idea how I could modify what ive done so that my global messages saying a player is using godmode/isnt using godmode can be changed to display the actual players name instead of just the word player?



Sorry, I'll delete my post there :C
pawn Code:
#define INFINITY                (Float:0x7F800000)
new GodMode[MAX_PLAYERS];



CMD:godmode(playerid, params[])
{
    if(GodMode[playerid] == 0) //god mode not set, lets set it
    {
        SetPlayerHealth(playerid, INFINITY);    //set the health to infinity
        GodMode[playerid] = 1;    //set godmode to true
        SendClientMessageToAll(COLOR_RED, " An Admin is now in god mode!");
    }
    else if(GodMode[playerid] == 1) //god mode set .. lets unset it
    {
        SetPlayerHealth(playerid, 100.0);    //set health to 100%
        GodMode[playerid] = 0;    //set godmode to false
        SendClientMessageToAll(COLOR_RED, "An Admin is now in god mode!");
    }
    return 1;
}
__________________
chєck σut mч rσlєplαч sєrvєr:
216.224.179.15:7777
Edward156 is offline   Reply With Quote
Old 03/06/2012, 12:04 AM   #8
Jonny5
Gangsta
 
Join Date: Mar 2012
Location: Mi, USA
Posts: 929
Reputation: 158
Default Re: Godmode Command Help[ZCMD]

@Edward156
thats not even close to what they asked!!!


@OP
yes you use format
and getplayername

something like
pawn Code:
new strOut[50],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName);
format(strOut,50,"%s has enabled godmode!",pName);
SendClientMessageToAll(0xFFFF00AA, strOut);
__________________
If your topic says "REP+", I ignore it.
Jonny5 is offline   Reply With Quote
Old 03/06/2012, 12:09 AM   #9
Kurtis96z
Little Clucker
 
Join Date: May 2012
Posts: 18
Reputation: 0
Default Re: Godmode Command Help[ZCMD]

Quote:
Originally Posted by Jonny5 View Post
@Edward156
thats not even close to what they asked!!!


@OP
yes you use format
and getplayername

something like
pawn Code:
new strOut[50],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName);
format(strOut,50,"%s has enabled godmode!",pName);
SendClientMessageToAll(0xFFFF00AA, strOut);
Ok I have done what you are explaining in both parts and I got 2 warnings.

C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(48 : warning 202: number of arguments does not match definition
C:\Users\Kurtis\Desktop\GTA - San Andreas\Pawno\gamemodes\learning.pwn(497) : warning 202: number of arguments does not match definition

Why did I receive these? what can I do to fix.

Edit: Oh, its because I do not have pName defined anywhere as anything right?
Edit: Nevermind
Kurtis96z is offline   Reply With Quote
Old 03/06/2012, 12:10 AM   #10
Jonny5
Gangsta
 
Join Date: Mar 2012
Location: Mi, USA
Posts: 929
Reputation: 158
Default Re: Godmode Command Help[ZCMD]

i missed the Len prop

Code:
GetPlayerName(playerid,pName, MAX_PLAYER_NAME);
sorry
__________________
If your topic says "REP+", I ignore it.
Jonny5 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
help zcmd command NeyMar96 Help Archive 11 12/08/2011 05:17 PM
Godmode Command Error Linus- Help Archive 2 31/12/2010 02:10 PM
/GodMode Command PinkFloydLover Help Archive 8 27/04/2010 02:29 PM
PM Command for ZCMD Torran Help Archive 7 10/03/2010 02:19 PM


All times are GMT. The time now is 07:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.