SA-MP Forums Archive
How would I add parameters to this? - 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: How would I add parameters to this? (/showthread.php?tid=607889)



How would I add parameters to this? - UnholyBeast - 25.05.2016

PHP Code:
public OnPlayerText(playerid, text[])
{
    new 
healcmd[] = "#heal", targetid, healthvalue;
    if(!
strcmp(text, healcmd, targetid, healthvalue))
    {
        if(!
IsPlayerAdmin(playerid)) return NormalPlayerChat(playerid, text);
        if(
IsPlayerAdmin(playerid))
        {
            new 
rcon_msg[144], healed_self[144];
            if(
sscanf(params, "ud", targetid, healthvalue)) return SendClientMessage(playerid, 0x32CD32CD, "USAGE: !heal <targetid> <amount of health>");
            if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0x32CD32CD, "That ID is not connected to a player.");
            if(
targetid == playerid)
            {
                
SetPlayerHealth(playerid, healthvalue);
                
format(healed_self, sizeof(healed_self), "You have set your own health to: %d", healthvalue);
                
SendClientMessage(playerid, 0x32CD32CD, healed_self);
            }
            
format(rcon_msg, sizeof(rcon_msg), "You have set \"%s(%d)'s\" health to: %d", PlayerName(playerid), playerid, healthvalue);
            
SetPlayerHealth(targetid, healthvalue);
            
SendClientMessage(playerid, -1, rcon_msg);
        }
        return 
0;
    }
    
NormalPlayerChat(playerid, text);
    return 
0;
} 



Re: How would I add parameters to this? - Naruto_Emilio - 25.05.2016

strcmp if string compare, you cant use it like that, I suggest you to start using zcmd & sscanf instead its much easier and easier to read & write aswell