Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: yazeen on March 26, 2011, 04:51:09 pm

Title: HELP NEEDED GUYS!!!
Post by: yazeen 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
Title: Re: HELP NEEDED GUYS!!!
Post by: [AoD]NC 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.
Title: Re: HELP NEEDED GUYS!!!
Post by: yazeen 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
Title: Re: HELP NEEDED GUYS!!!
Post by: yazeen on March 26, 2011, 05:17:58 pm
And i this too The player should be near [the player who use /c heal [Playerid] ]
Title: Re: HELP NEEDED GUYS!!!
Post by: tato 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;
}
Title: Re: HELP NEEDED GUYS!!!
Post by: cycu 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  ::)
Title: Re: HELP NEEDED GUYS!!!
Post by: tato 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;
}
Title: Re: HELP NEEDED GUYS!!!
Post by: cycu 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.
Title: Re: HELP NEEDED GUYS!!!
Post by: yazeen 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.
Title: Re: HELP NEEDED GUYS!!!
Post by: Madara 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. ;)
Title: Re: HELP NEEDED GUYS!!!
Post by: yazeen 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!!!
Title: Re: HELP NEEDED GUYS!!!
Post by: yazeen on March 27, 2011, 03:18:37 pm
Topic Locked So many Answers got! Thx everyoene
Title: Re: HELP NEEDED GUYS!!!
Post by: tato on March 27, 2011, 07:13:42 pm
ok  ;D