Oh look!
#1

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)
Reply
#2

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
Reply
#3

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.
Reply
#4

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;

Reply
#5

Thank you all
Reply
#6

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;
}
Reply
#7

The code I tried still had two errors


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

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;

Reply
#9

Check my post after

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)