SA-MP Forums Archive
Oh look! - 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)
+--- Thread: Oh look! (/showthread.php?tid=541403)



Oh look! - mkmk - 11.10.2014

You probably all know me by now because this is my third time asking for help!
So, I was scripting a /heal command and it all bugged out, the command above it works perfectly so I have no idea what's wrong.

This is of both commands, the first one works fully:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/SpawnM4", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid, 31, 10000);

	
	}
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/heal", cmdtext, true, 10) == 0)
	{
	
	 	SendPlayerHealth(playerid, 100);
	 	SendClientMessage(playerid, "You have been healed!");
	 	return 1;
	 }
	 return 0;
}
ERROR CODES:
: error 021: symbol already defined: "OnPlayerCommandText"
: error 017: undefined symbol "SendPlayerHealth"
: error 035: argument type mismatch (argument 2)


Re: Oh look! - IceBilizard - 11.10.2014

Quote:
Originally Posted by mkmk
Посмотреть сообщение
ERROR CODES:
: error 021: symbol already defined: "OnPlayerCommandText"
: error 017: undefined symbol "SendPlayerHealth"
: error 035: argument type mismatch (argument 2)
You have defined 2 times OnPlayerCommandText

and look here for this function

https://sampwiki.blast.hk/wiki/OnPlayerCommandText


Re: Oh look! - Abagail - 11.10.2014

You can't call a function twice in the same script, - furthermore commands should be "together" in the callback.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/SpawnM4", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid, 31, 10000);
    }

    if (strcmp("/heal", cmdtext, true, 10) == 0)
    {
   
        SendPlayerHealth(playerid, 100);
        SendClientMessage(playerid, "You have been healed!");
        return 1;
     }
        return false;
}
I'd how-ever recommend using ZCMD or another command processor.


Re : Oh look! - Dutheil - 11.10.2014

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
        if (
strcmp("/SpawnM4"cmdtexttrue10) == 0)
        {
            
GivePlayerWeapon(playerid3110000);
        
        return 
1;
    }
    if (
strcmp("/heal"cmdtexttrue10) == 0)
    {
         
SendPlayerHealth(playerid100);
         
SendClientMessage(playerid"You have been healed!");
         return 
1;
    }
    
    return 
0;




Re: Oh look! - mkmk - 11.10.2014

Thank you all


Re: Oh look! - IceBilizard - 11.10.2014

little mistake on your codes guys

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/SpawnM4", cmdtext, true, 10) == 0)
        {
            GivePlayerWeapon(playerid, 31, 10000);
            return 1;
        }
        if (strcmp("/heal", cmdtext, true, 10) == 0)
        {
         SetPlayerHealth(playerid, 100);
         SendClientMessage(playerid, -1, "You have been healed!");
         return 1;
        }
        return 0;
}



Re: Oh look! - mkmk - 11.10.2014

The code I tried still had two errors


: error 017: undefined symbol "SendPlayerHealth"
: error 035: argument type mismatch (argument 2)


Re: Oh look! - YanLanger - 11.10.2014

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/SpawnM4"cmdtexttrue10) == 0)
    {
        
GivePlayerWeapon(playerid3110000);
    }

    if (
strcmp("/heal"cmdtexttrue10) == 0)
    {
    
        
SetPlayerHealth(playerid100);
        
SendClientMessage(playerid"You have been healed!");
        return 
1;
     }
        return 
false;




Re: Oh look! - IceBilizard - 11.10.2014

Check my post after

Quote:
Originally Posted by mkmk
Посмотреть сообщение
Thank you all



Re: Oh look! - mkmk - 11.10.2014

Quote:
Originally Posted by IceBilizard
Посмотреть сообщение
Check my post after
I did, yet still have two errors