[HELP] /aheal command !
#1

What i have done wrong ?

pawn Код:
if(strcmp(cmd, "/aheal", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        new id;
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /heal [playerid]");
            return 1;
        }
        giveplayerid = strval(tmp);
        if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 101)
        {
            format(string, sizeof(string), "Server :  %s Has been slapped by admin %s.", PlayerName[giveplayerid], PlayerName[playerid]);
            SendClientMessageToAll(COLOR_RED, string);
        }
        else
        {
        SetPlayerHealth(id, 100.0);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
        }
        return 1;
}
Error :
pawn Код:
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(9813) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
That line is :
pawn Код:
else
Reply
#2

try this
Код:
	if(strcmp("/aheal", cmdtext, true, 10) == 0) 
	{
			        if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 101)
		{
			GetPlayerName(playerid, sendername, sizeof(sendername));
		{
				SetPlayerHealth(playerid,100);
				SetPlayerArmour(playerid,100);
			}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command !");
			}
		return 1;
		}
I never tested it xD but it should work
Reply
#3

It workes but i want 2 more things .

1 : To not heal myself only , heal the others too like /aheal [id2]
2 : When i heal a player even myself a message to appear to whole server : Like :
pawn Код:
{
            format(string, sizeof(string), "Server :  %s Has been healed by admin %s.", PlayerName[giveplayerid], PlayerName[playerid]);
            SendClientMessageToAll(COLOR_RED, string);
        }
Reply
#4

try this
Код:
	if(strcmp(cmd, "/heal", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /heal [playerid/PartOfName]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /heal [playerid/PartOfName]");
				return 1;
			}
			if(IsPlayerConnected(giveplayerid))
			{
			    if(giveplayerid != INVALID_PLAYER_ID)
			    {
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					GetPlayerName(playerid, sendername, sizeof(sendername));
					if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 101)
					{
							new Float:tempheal;
							GetPlayerHealth(giveplayerid,tempheal);
							if(tempheal >= 100.0)
							{
								SendClientMessage(playerid, COLOR_GRAD1,"   You healed that player succesfully !");
								return 1;
							}
							SetPlayerHealth(giveplayerid, 100);
							PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
							SendClientMessage(giveplayerid, COLOR_YELLOW, "   You have been fully healed.");
							{
           					 format(string, sizeof(string), "Server :  %s Has been healed by admin %s.", PlayerName[giveplayerid], PlayerName[playerid]);
            					SendClientMessageToAll(COLOR_RED, string);
        						}


					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
						return 1;
					}
				}
			}
			else
			{
				format(string, sizeof(string), "   That player is offline or you mistyped its name!", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
I'm not sure it will work but if you can script little bit you can fix it.
Reply
#5

This one edited by me works . But it only works if i tipe : /heal 0 asd or some keywords .And i want to remove that . Can you remove that for me please ? And one more thing i want to remove the : You have been succesfully healed message please !

pawn Код:
if(strcmp(cmd, "/aheal", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aheal [playerid/PartOfName]");
                return 1;
            }
            giveplayerid = strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aheal [playerid/PartOfName]");
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 101)
                    {
                            new Float:tempheal;
                            GetPlayerHealth(giveplayerid,tempheal);
                            if(tempheal >= 100.0)
                            {
                                SendClientMessage(playerid, COLOR_GRAD1,"   You healed that player succesfully !");
                                return 1;
                            }
                            SetPlayerHealth(giveplayerid, 100);
                            PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
                            SendClientMessage(giveplayerid, COLOR_YELLOW, "   You have been fully healed.");
                            {
                             format(string, sizeof(string), "Server :  %s Has been healed by admin %s.", PlayerName[giveplayerid], PlayerName[playerid]);
                                SendClientMessageToAll(COLOR_RED, string);
                                }


                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
                        return 1;
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "   That player is offline or you mistyped its name!", giveplayerid);
                SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
    }
Reply
#6

BUMP !!!!
Reply
#7

Quote:
Originally Posted by [Aka]Dragonu
Посмотреть сообщение
BUMP !!!!
It may help you to read the wiki (especially on strtok and OnPlayerCommandText)
- If this thread is not properly answered when i get on my laptop i will attempt to help you

This forum requires that you wait 120 seconds between posts. Please try again in 8 seconds.

Edit: Try this...
pawn Код:
if(strcmp("/aheal", cmdtext) == 0)
{
    new idx, pid, tmp, pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME], string[128];
    tmp = strtok(cmdtext, idx);
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Administration Level Required");
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOUR, "Usage: /aheal [playerid]");
    pid = strval(tmp);
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR, "This player is not connected");
   
    SetPlayerHealth(pid, 100.0);
   
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(pid, pName2, sizeof(pName2));
    format(string, sizeof(string), "%s was healed by %s", pName2, pName);
    SendClientMessageToAll(COLOUR, string);
   
}

//Usage: /aheal [playerid]
Remember to change COLOUR to the colour (color) that you want...
Reply
#8

It gives me a load of errors . And i have changed COLOUR !
Reply
#9

i think i can give you a bit easier script you can Edit when i get finished
Reply
#10

Here it is something might work for ya
pawn Код:
if (strcmp("/aheal", cmdtext, true, 6) == 0)
        {
        if(!IsPlayerAdmin(playerid))return 1;
        SendClientMessage(playerid, COLOR_GOLD, "You Are Not A Admin, You can't use this command");

        new cmd[128], tmp[128], idx;
        new string[128];
        cmd = strtok(cmdtext, idx);

        tmp = strtok(cmdtext, idx);

        if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GOLD, "Usage: /aheal[player id]");
        new playeree = strval(tmp);
        if(!IsPlayerConnected(playeree)) return SendClientMessage(playerid, COLOR_GOLD, "Player is not connected.");


        new playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
        GetPlayerName(playeree, playername, MAX_PLAYER_NAME);
        GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
       
        format(string, sizeof(string), "Admin %s Has Healed %s", adminname, playername);
        SendClientMessageToAll(COLOR_GOLD, string);
       
        SetPlayerHealth(playeree, 100);
        return 1;
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)