Author Topic: HELP NEEDED GUYS!!!  (Read 4470 times)

0 Members and 3 Guests are viewing this topic.

yazeen

  • Guest
HELP NEEDED GUYS!!!
« on: March 26, 2011, 04:51:09 pm »
I want a Command That a Player Can Heal other Player using /c heal [Playerid]

Please Help me

Offline [AoD]NC

  • VC:MP Beta Tester
  • VC:MP Veteran
  • *
  • Posts: 616
  • AoD forever!
    • View Profile
    • KURWA MAĆ
Re: HELP NEEDED GUYS!!!
« Reply #1 on: March 26, 2011, 05: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.

yazeen

  • Guest
Re: HELP NEEDED GUYS!!!
« Reply #2 on: March 26, 2011, 05:16:49 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

  • Guest
Re: HELP NEEDED GUYS!!!
« Reply #3 on: March 26, 2011, 05:17:58 pm »
And i this too The player should be near [the player who use /c heal [Playerid] ]

Offline tato

  • Made Man
  • ***
  • Posts: 106
  • I bet u don't know me!
    • View Profile
    • EA Server
Re: HELP NEEDED GUYS!!!
« Reply #4 on: March 26, 2011, 07:08:26 pm »
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
Code: [Select]
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;
}
« Last Edit: March 26, 2011, 10:51:20 pm by tato »

Offline cycu

  • VC:MP Beta Tester
  • Street Thug
  • *
  • Posts: 19
    • View Profile
Re: HELP NEEDED GUYS!!!
« Reply #5 on: March 26, 2011, 09:13:43 pm »
Code: [Select]
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:

Code: [Select]
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  ::)
« Last Edit: March 26, 2011, 10:22:09 pm by cycu »

Offline tato

  • Made Man
  • ***
  • Posts: 106
  • I bet u don't know me!
    • View Profile
    • EA Server
Re: HELP NEEDED GUYS!!!
« Reply #6 on: March 26, 2011, 11: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
Code: [Select]
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;
}

Offline cycu

  • VC:MP Beta Tester
  • Street Thug
  • *
  • Posts: 19
    • View Profile
Re: HELP NEEDED GUYS!!!
« Reply #7 on: March 26, 2011, 11:37:00 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
Code: [Select]
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

  • Guest
Re: HELP NEEDED GUYS!!!
« Reply #8 on: March 27, 2011, 06:55:29 am »
Code: [Select]
}
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:
Code: [Select]
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.

Offline Madara

  • Street Thug
  • *
  • Posts: 48
    • View Profile
Re: HELP NEEDED GUYS!!!
« Reply #9 on: March 27, 2011, 10: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.

Code: [Select]
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

  • Guest
Re: HELP NEEDED GUYS!!!
« Reply #10 on: March 27, 2011, 10:52:16 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.

Code: [Select]
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

  • Guest
Re: HELP NEEDED GUYS!!!
« Reply #11 on: March 27, 2011, 03:18:37 pm »
Topic Locked So many Answers got! Thx everyoene

Offline tato

  • Made Man
  • ***
  • Posts: 106
  • I bet u don't know me!
    • View Profile
    • EA Server
Re: HELP NEEDED GUYS!!!
« Reply #12 on: March 27, 2011, 07:13:42 pm »
ok  ;D