PDA

View Full Version : Medic class cmds !


Michael@Belgium
01/02/2011, 04:01 PM
So i'm beginning to script some cmds for the MEDIC class (like /healme, /heal <playerid>). I have that for solution:
(1) /healme cmd

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 (c) 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 ??--------------

Marricio
01/02/2011, 04:11 PM
if (strcmp(cmdtext,"/healme", true) == 0)
{
if (gTeam[playerid] == MEDIC) //line 757
{
SetPlayerHealth(playerid, 100);
return 1;
}
}

JaTochNietDan
01/02/2011, 04:11 PM
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

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!

Marricio
01/02/2011, 04:14 PM
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

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.

Michael@Belgium
01/02/2011, 04:20 PM
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

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)

Marricio
01/02/2011, 04:33 PM
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.

Michael@Belgium
01/02/2011, 05:06 PM
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 ! :D It works !

Shepster
09/10/2011, 06:14 PM
how to put this into my gamemode?