Medic class cmds ! -
Michael@Belgium - 01.02.2011
So i'm beginning to script some cmds for the MEDIC class (like /healme, /heal <playerid>). I have that for solution:
(1) /healme cmd
pawn Код:
if (gTeam[playerid] = MEDIC) //line 757
{
if (strcmp(cmdtext,"/healme", true) == 0)
{
SetPlayerHealth(playerid, 100);
return 1;
}
}
BTW i got this warning:
Код:
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\PAT.pwn(757) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
(2) /heal <playerid>
I have tried a lot of ... codes but i don't find one :S Can you give me the code for /heal <playerid>
!! But the medic has to stand near of the player ... !!
SOLVED
-------I KNOW ONLY THESE CMDS FOR THE MEDIC CLASS, CAN YOU GIVE ME MORE ??--------------
Re: Medic class cmds ! -
Marricio - 01.02.2011
pawn Код:
if (strcmp(cmdtext,"/healme", true) == 0)
{
if (gTeam[playerid] == MEDIC) //line 757
{
SetPlayerHealth(playerid, 100);
return 1;
}
}
Re: Medic class cmds ! -
JaTochNietDan - 01.02.2011
Your syntax for the if statement is incorrect.
= is the assign operator, it is used for assigning a value to something
== means equals to, it is used for comparing two values
pawn Код:
if (gTeam[playerid] == MEDIC)
Additionally I think the if statement should be placed within the if statement containing the string comparison for logical reasons, but that's up to you.
As for a command with parameters, you should look into using DCMD or ZCMD and sscanf. They should help you significantly in making commands with multiple parameters, you should also use search for examples, there's plenty of them already around the forums!
Re: Medic class cmds ! -
Marricio - 01.02.2011
Quote:
Originally Posted by JaTochNietDan
Your syntax for the if statement is incorrect.
= is the assign operator, it is used for assigning a value to something
== means equals to, it is used for comparing two values
pawn Код:
if (gTeam[playerid] == MEDIC)
Additionally I think the if statement should be placed within the command for logical reasons, but that's up to you.
As for a command with parameters, you should look into using DCMD or ZCMD and sscanf. They should help you significantly in making commands with multiple parameters, you should also use search for examples, there's plenty of them already around the forums!
|
Oh yea, didn't noticed that, my post is edited.
Re: Medic class cmds ! -
Michael@Belgium - 01.02.2011
Quote:
Originally Posted by JaTochNietDan
Your syntax for the if statement is incorrect.
= is the assign operator, it is used for assigning a value to something
== means equals to, it is used for comparing two values
pawn Код:
if (gTeam[playerid] == MEDIC)
Additionally I think the if statement should be placed within the if statement containing the string comparison for logical reasons, but that's up to you.
As for a command with parameters, you should look into using DCMD or ZCMD and sscanf. They should help you significantly in making commands with multiple parameters, you should also use search for examples, there's plenty of them already around the forums!
|
ok the warning is gone ... but you know /heal <playerid> ? (a)
Re: Medic class cmds ! -
Marricio - 01.02.2011
pawn Код:
if(strcmp("/heal", cmd, true) == 0)
{
if (gTeam[playerid] == MEDIC)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /heal [id]");
}
new id = strval(tmp);
new pid = playerid;
if(!IsPlayerConnected(id))
{
return SendClientMessage(playerid,COLOR_GREY,"AdmCmd: This player is not online!");
}
new Float:X,Float:Y,Float:Z, string[128], name[MAX_PLAYER_NAME];
GetPlayerName(id,name,128);
GetPlayerPos(id,X,Y,Z);
if(IsPlayerInRangeOfPoint(playerid,3,X,Y,Z))
{
format(string,128,"[INFO] Medic %s[%d] has healed you!", name, pid);
SetPlayerHealth(id,100);
SendClientMessage(id,COLOR_GREY,string);
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"You're not near the player!");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY,"You're not a Medic!");
return 1;
}
}
Not tested, might work.
Re: Medic class cmds ! -
Michael@Belgium - 01.02.2011
Quote:
Originally Posted by Marricio
pawn Код:
if(strcmp("/heal", cmd, true) == 0) { if (gTeam[playerid] == MEDIC) { tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { return SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /heal [id]"); } new id = strval(tmp); new pid = playerid; if(!IsPlayerConnected(id)) { return SendClientMessage(playerid,COLOR_GREY,"AdmCmd: This player is not online!"); } new Float:X,Float:Y,Float:Z, string[128], name[MAX_PLAYER_NAME]; GetPlayerName(id,name,128); GetPlayerPos(id,X,Y,Z); if(IsPlayerInRangeOfPoint(playerid,3,X,Y,Z)) { format(string,128,"[INFO] Medic %s[%d] has healed you!", name, pid); SetPlayerHealth(id,100); SendClientMessage(id,COLOR_GREY,string); return 1; } else { SendClientMessage(playerid,COLOR_RED,"You're not near the player!"); } } else { SendClientMessage(playerid,COLOR_GREY,"You're not a Medic!"); return 1; } }
Not tested, might work.
|
GREAT !
It works !
Re: Medic class cmds ! -
Shepster - 09.10.2011
how to put this into my gamemode?