• Welcome to Vice City Multiplayer.
 

HELP NEEDED GUYS!!!

Started by yazeen, March 26, 2011, 01:51:09 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

yazeen

I want a Command That a Player Can Heal other Player using /c heal [Playerid]

Please Help me

[AoD]NC

Look at the !heal command. It contains probably something like SetPlayerHealth( player, 100 ). Instead of player, you have to use there the FindPlayer from text function.

yazeen

Quote from: [AoD]NC on March 26, 2011, 02:13:33 PM
Look at the !heal command. It contains probably something like SetPlayerHealth( player, 100 ). Instead of player, you have to use there the FindPlayer from text function.

Find Player From text or FindplayeridFromString

Please Help when i make it shows Error

yazeen

And i this too The player should be near [the player who use /c heal [Playerid] ]

tato

#4
here is the command but i need to fix it i just gave to you maybe you got an idea so if you can fix it perfect! but i will try to fix it
else if (strcmp(cmd, "heal", true) == 0) {
tmp = strtok(cmdtext, idx);
new snick[256], plr,  szMsg[256];
snick = strtok(cmdtext, idx), plr = FindPlayerIDFromString(snick);
if (!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN, "Usage: /c heal [Nick/ID]");
else {
format(szMsg,sizeof(szMsg),"%s Healed Player:[ %s ]",gPlayers[playerid],gPlayers[plr]);
SendClientMessageToAll(COLOR_GREEN,szMsg);
SetPlayerHealth(plr,100);
}
return 1;
}





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

cycu

#5
if (strcmp(cmd, "heal", true) == 0)
{
new
tmp[20],
id;
tmp = strtok(cmdtext, index);
if (strlen(tmp))
{
id = strval(tmp);
if (IsPlayerConnected(id))
{
SetPlayerHealth(id, 100.0);
SendClientMessage(id, 0x00FF00AA, "You have been healed");
SendClientMessage(playerid, 0x00FF00AA, "Player healed");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Player not found");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
}
return 1;
}


And at the end of the script you have to add strtok definition:

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

I recommend looking into SA-MP wiki there is a lot useful stuff about pawn.

You can find the command and explanation here:

http://wiki.sa-mp.com/wiki/Strtok

I wish someone re defined dcmd for vc-mp  ::)

tato

is kind of like this but is bugged i need to fix it here is the command but i need to fix it i just gave to you maybe you got an idea so if you can fix it perfect! but i will try to fix it
else if (strcmp(cmd, "heal", true) == 0) {
tmp = strtok(cmdtext, idx);
new snick[256], plr,  szMsg[256];
snick = strtok(cmdtext, idx), plr = FindPlayerIDFromString(snick);
if (!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN, "Usage: /c heal [Nick/ID]");
else {
format(szMsg,sizeof(szMsg),"%s Healed Player:[ %s ]",gPlayers[playerid],gPlayers[plr]);
SendClientMessageToAll(COLOR_GREEN,szMsg);
SetPlayerHealth(plr,100);
}
return 1;
}





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

cycu

Quote from: tato on March 26, 2011, 08:06:13 PM
is kind of like this but is bugged i need to fix it here is the command but i need to fix it i just gave to you maybe you got an idea so if you can fix it perfect! but i will try to fix it
else if (strcmp(cmd, "heal", true) == 0) {
tmp = strtok(cmdtext, idx);
new snick[256], plr,  szMsg[256];
snick = strtok(cmdtext, idx), plr = FindPlayerIDFromString(snick);
if (!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN, "Usage: /c heal [Nick/ID]");
else {
format(szMsg,sizeof(szMsg),"%s Healed Player:[ %s ]",gPlayers[playerid],gPlayers[plr]);
SendClientMessageToAll(COLOR_GREEN,szMsg);
SetPlayerHealth(plr,100);
}
return 1;
}


In first place i recommend you NOT using mode.pwn but make your own from scratch, this gm is so much NOT newbie friendly and sooooooo much against server performance.

yazeen

}
if (strcmp(cmd, "heal", true) == 0)
{
new
tmp[20],
             cash,
             plr;
             
tmp = strtok(cmdtext, idx);
cash = GetPlayerMoney(plr);
plr = FindPlayerIDFromString(tmp);
{

if (IsPlayerConnected(playerid))
if (strlen(tmp))
if(Medic[playerid]== 1))
if(cash >= 100))
if(CallMedic[plr] == 1))
{
SetPlayerHealth(playerid, 100.0);
SendClientMessage(plr, orange, "You have been healed by Medic");
SendClientMessage(playerid, orange, "Player healed You Earned 300$");
SetPlayerMoney(playerid,cash+300);
SetPlayerMoney(plr,cash-100);

}
else
{
SendClientMessage(playerid, orange, "No Such Player");
}
}
else
{
SendClientMessage(playerid, orange, "Usage: /c Heal [Playerid]);
}
}
else
{
  SendClientMessage(playerid, orange, "This Player Do Not Have Enough Cash");
}
}
else
{
SendClientMessage(playerid, orange, "This Player Has Not Called Medic");
}
return 1;


Shows Errors:
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(813) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(820) : error 029: invalid expression, assumed zero
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(820 -- 821) : warning 215: expression has no effect
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(821) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(821) : warning 217: loose indentation
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(821) : error 029: invalid expression, assumed zero
C:\Documents and Settings\yachu\Desktop\Vcmp\Gamemodes\RPG Server\RPG Server\gamemodes\FSRPG.pwn(821) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

Madara

To send "heal" a friend, use this command is similar to a "sethp" but in this, sent him to default a player for his "health " to 100.

else if (strcmp(cmd, "healfriend", true) == 0) {
new sendmsn[256]; tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) {format(sendmsn, 256,"[Syntax] - The correct use: /c %s <playerid/name>.",cmd); SendClientMessage(playerid,0x04A36BFF,MSN);}
else {
     new toheal = FindPlayerIDFromString(tmp);
     if (toheal == INACTIVE_PLAYER_ID) SendClientMessage(playerid, 0x04A36BFF,"[Error] - Unknown player.");
     else {
                  format(sendmsn,256, "%s send heal to: %s.",gPlayers[playerid],gPlayers[toheal]);
                  SendClientMessageToAll(0x377DFFFF,sendmsn);
                  SetPlayerHealth(toheal,100);
                  }
}
return 1;
}


I hope it serves and if any problem, please tell me.

Greeting. ;)

yazeen

Quote from: Madara on March 27, 2011, 08:43:30 AM
To send "heal" a friend, use this command is similar to a "sethp" but in this, sent him to default a player for his "health " to 100.

else if (strcmp(cmd, "healfriend", true) == 0) {
new sendmsn[256]; tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) {format(sendmsn, 256,"[Syntax] - The correct use: /c %s <playerid/name>.",cmd); SendClientMessage(playerid,0x04A36BFF,MSN);}
else {
     new toheal = FindPlayerIDFromString(tmp);
     if (toheal == INACTIVE_PLAYER_ID) SendClientMessage(playerid, 0x04A36BFF,"[Error] - Unknown player.");
     else {
                  format(sendmsn,256, "%s send heal to: %s.",gPlayers[playerid],gPlayers[toheal]);
                  SendClientMessageToAll(0x377DFFFF,sendmsn);
                  SetPlayerHealth(toheal,100);
                  }
}
return 1;
}


I hope it serves and if any problem, please tell me.

Greeting. ;)

THXXXXXx!!!

yazeen

Topic Locked So many Answers got! Thx everyoene

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b