SA-MP Forums Archive
Noob Question *In Need Of Help ASAP* - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Noob Question *In Need Of Help ASAP* (/showthread.php?tid=201231)



Noob Question *In Need Of Help ASAP* - [DBZ]Ali - 20.12.2010

Why doesn't this work:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/Ikky Wikky Medicine *puke*", cmdtext, true, 27) == 0)
	{
		GetPlayerHealth(playerid) == < 99;
		{
		    SendClientMessage(playerid,0xFF0000,"Lies you has full health already!");
		    }
		}
		else
		GetPlayerHealth(playerid) == > 100;
		{
		    SendClientMessage(playerid,0xFF0000,"There ya go nub");
		    SetPlayerHealth(100);
		    GivePlayerMoney(playerid,-1337);
			}
		}
		return 1;
	}
	return 0;
}
Код:
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(94) : warning 235: public function lacks forward declaration (symbol "OnPlayerPrivmsg")
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(103) : warning 202: number of arguments does not match definition
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(103) : error 029: invalid expression, assumed zero
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(103) : warning 215: expression has no effect
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(109) : warning 202: number of arguments does not match definition
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(109) : error 029: invalid expression, assumed zero
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(109) : warning 217: loose indentation
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(109) : warning 215: expression has no effect
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(112) : warning 202: number of arguments does not match definition
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(116) : error 010: invalid function or declaration
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(118) : error 010: invalid function or declaration
C:\Users\hp\Desktop\Stuff\Server\filterscripts\GettyHealth.pwn(121) : warning 235: public function lacks forward declaration (symbol "OnPlayerInfoChange")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
And ignore the warnings..
And don't troll plox
I want the guy to get full health only if his health is below 100


Re: Noob Question *In Need Of Help ASAP* - blackwave - 20.12.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Ikky Wikky Medicine *puke*", cmdtext, true, 27) == 0)
    {
        if(GetPlayerHealth(playerid) > 99)
        {
            SendClientMessage(playerid,0xFF0000,"Lies you has full health already!");
            }
        }
        else
        if(GetPlayerHealth(playerid)  < 99)
        {
            SendClientMessage(playerid,0xFF0000,"There ya go nub");
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-1337);
            }
        }
        return 1;
    }
    return 0;
}



Respuesta: Noob Question *In Need Of Help ASAP* - admantis - 20.12.2010

@blackwave: it will return errors due a extra bracket and it will also return SERVER: Unknown Command

@Post author: you need to learn to script
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Ikky Wikky Medicine *puke*", cmdtext, true) == 0)
    {
        if (GetPlayerHealth(playerid) > 94)
        {
            return SendClientMessage(playerid,0xFF0000,"Lies you has full health already!");
        }
        else if (GetPlayerHealth(playerid) < 100)
        {
            SendClientMessage(playerid,0xFF0000,"There ya go nub");
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-1337);
            return 1;
        }
    }
    return 0;
}



AW: Noob Question *In Need Of Help ASAP* - [SU]Balli - 20.12.2010

Код:
if (strcmp("/Ikky Wikky Medicine *puke*", cmdtext, true, 10) == 0)
	{
        new Float:health;
    	GetPlayerHealth(playerid,health);
    	if (health > 100.0)
		{
		    SendClientMessage(playerid,0xFF0000,"Lies you has full health already!");
		    }
		}
		else
		{
		new Float:health;
        GetPlayerHealth(playerid,health);
    	if (health < 99.0)
		{
		    SendClientMessage(playerid,0xFF0000,"There ya go nub");
		    SetPlayerHealth(playerid, 100);
		    GivePlayerMoney(playerid,-1337);
			}
		}
		return 1;
	}
//Edit: Dam u both were faster D=


Respuesta: AW: Noob Question *In Need Of Help ASAP* - admantis - 20.12.2010

Quote:
Originally Posted by [SU]Balli
Посмотреть сообщение
Код:
if (strcmp("/Ikky Wikky Medicine *puke*", cmdtext, true, 10) == 0)
	{
        new Float:health;
    	GetPlayerHealth(playerid,health);
    	if (health > 100.0)
		{
		    SendClientMessage(playerid,0xFF0000,"Lies you has full health already!");
		    }
		}
		else
		{
		new Float:health;
        GetPlayerHealth(playerid,health);
    	if (health < 99.0)
		{
		    SendClientMessage(playerid,0xFF0000,"There ya go nub");
		    SetPlayerHealth(playerid, 100);
		    GivePlayerMoney(playerid,-1337);
			}
		}
		return 1;
	}
//Edit: Dam u both were faster D=
it wouldn't work because it checks if player health is HIGHER THAN 100, that means if player health is 101 or higher, which is umpossible unless you have godmode. proper code would be
pawn Код:
if (health > 99) return health;



Re: Noob Question *In Need Of Help ASAP* - blackwave - 20.12.2010

Oh, didn't see that bracket.


Re: Noob Question *In Need Of Help ASAP* - [DBZ]Ali - 21.12.2010

Thanks, and as I said I am a noob so don't be mad