Explosion CMD won't take health!
#1

Hi all!

I made this explode CMD, wanted to ask, with which function should I reduce the player's health for 25?
'Cause the explosion itself won't cause any damage, so how can I set the player's health for 25 lower? I already thought about "SetPlayerHealth", but this wouldn't work, right?

PHP код:
CMD:explode(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 5)
    {
            new 
Target;
            if(
sscanf(params"u"Target)) SendClientMessage(playeridCOLOR_LIGHTBLUE"USAGE: /explode [playerid]");
            if(!
IsPlayerConnected(Target))
                return 
SendClientMessage(playeridCOLOR_GREY"ERROR:Player is not connected!");
            if(!
sscanf(params"u"Target))
            {
                
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
                
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
                
//if(PlayerAcc[Target][AdminLevel] >= PlayerAcc[playerid][AdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cant perform this on Admins that are equal or higher than your level!");
                
new Float:X;
                new 
Float:Y;
                new 
Float:Z;
                
GetPlayerPos(Target,X,Y,Z);
                
CreateExplosion(X,Y,Z,1,10);
                new 
tname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,tname,sizeof(tname));
                new 
pname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,pname,sizeof(pname));
                new 
pstring[256];
                new 
tstring[256];
                new 
astring[256];
                
format(pstring,sizeof(pstring),"You have exploded player %s(%d)",tname,Target);
                
format(tstring,sizeof(tstring),"Administrator %s has exploded you!",pname);
                
format(astring,sizeof(astring),"Administrator %s has exploded %s!",pname,tname);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,pstring);
                
SendClientMessage(playerid,TEAM_GROVE_COLOR,tstring);
                
SendClientMessageToAll(COLOR_GOLD,astring);
            }
            
    }
    else return 
SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
    return 
1;

Reply
#2

Yes you could use SetPlayerHealth and GetPlayerHealth.
pawn Код:
new Float:health;
GetPlayerHealth(Target,health);
SetPlayerHealth(Target, health -25);
Reply
#3

1.) Those string sizes are ridiculous.. Double what you need.. Use 128.
2.) You can use one string for ALL of those.

pawn Код:
format(pstring, sizeof(pstring), "...");
SendClientMessage(playerid, COLOR_LIGHTBLUE, pstring);
format(pstring, sizeof(pstring), "...");
SendClientMessage(playerid, COLOR_LIGHTBLUE, pstring);
You can reuse strings.
Reply
#4

@2KY

Fixed, ty!


@Fj0rtiz

Thank you, it worked! But it still isn't what I want! You know, the player doesn't explode, he just gets fire on this head with a sound! What I want is, that the player really should get blown up! Like when a car explodes and you stand near it, you get blown up and fall a few meters away! You know what I mean?? ><
Code again:

PHP код:
COMMAND:explode(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 5)
    {
            new 
Target;
            if(
sscanf(params"u"Target)) SendClientMessage(playeridCOLOR_LIGHTBLUE"USAGE: /explode [playerid]");
            if(!
IsPlayerConnected(Target))
                return 
SendClientMessage(playeridCOLOR_GREY"ERROR:Player is not connected!");
            if(!
sscanf(params"u"Target))
            {
                
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
                
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"ERROR: Wrong player ID");
                
//if(PlayerAcc[Target][AdminLevel] >= PlayerAcc[playerid][AdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cant perform this on Admins that are equal or higher than your level!");
                
new Float:X;
                new 
Float:Y;
                new 
Float:Z;
                new 
Float:health;
                
GetPlayerPos(Target,X,Y,Z);
                
CreateExplosion(X,Y,Z,1,10);
                
GetPlayerHealth(Target,health);
                
SetPlayerHealth(Targethealth -25);
                new 
tname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,tname,sizeof(tname));
                new 
pname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,pname,sizeof(pname));
                new 
pstring[128];
                new 
tstring[128];
                new 
astring[128];
                
format(pstring,sizeof(pstring),"You have exploded player %s(%d)",tname,Target);
                
format(tstring,sizeof(tstring),"Administrator %s has exploded you!",pname);
                
format(astring,sizeof(astring),"Administrator %s has exploded %s!",pname,tname);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,pstring);
                
SendClientMessage(playerid,TEAM_GROVE_COLOR,tstring);
                
SendClientMessageToAll(COLOR_GOLD,astring);
            }
            
    }
    else return 
SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 5 to use this command!");
    return 
1;

Reply
#5

Nyone knows how to do that?
Reply
#6

GetPlayerPos and SetPlayerPos.. but it will be like a teleport
Reply
#7

You mean something like that?
PHP код:
                    new Float:xFloat:yFloat:z;
                    
GetPlayerPos(playeridxyz);
                    
SetPlayerPos(IDx+1y+1z); 
Would be cool, if you'd explain that a little more with the fixed function!:/
Reply
#8

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
You mean something like that?
PHP код:
                    new Float:xFloat:yFloat:z;
                    
GetPlayerPos(playeridxyz);
                    
SetPlayerPos(IDx+1y+1z); 
yeah like that. you can just increase the "x+2..or 3 something". just test the distance and change to whatever you would need.
Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
Would be cool, if you'd explain that a little more with the fixed function!:/
there are errors? and if you want the explode command for some health hackers or such. SetPlayerHealth will not work i think. cuz it will force the health to go down by 25. only if it regenerates you can catch him
Reply
#9

Actually, for blowing away you'd better use this:

Wiki:SetPlayerVelocity

Adjust the floats to fit your needs. I suggest using something around 0.1-0.3.
Reply
#10

@Universal

Yeah thanks, but damn, it's still...how should I explain....without a "feeling", you know? It looks like the player flies around and then burns. But I want, that it will happen in the same way such as he gets blown away when a car explodes...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)