Need help with my commands
#1

So i've just started learning to script few days ago. Made some IRC commands, but some of them are not working so i posted here to see if i could learn anything.

This is my script:
Код:
IRCCMD:sethealth(botid, channel[], user[], host[], params[])
{
	if (IRC_IsVoice(botid, channel, user))
	{
	    new tmp[64], playerid, amount; //Line 477
	    if (sscanf(params, "dS(Insert Amount)[64]", playerid, amount))
	    {
	        return 1;
		}
		if (IsPlayerConnected(playerid))
		{
		    new msg[128], name[MAX_PLAYER_NAME];
		    GetPlayerName(playerid, name, sizeof(name));
		    format(msg, sizeof(msg), "%s has set %s health to %s", user, name, amount);
		    IRC_GroupSay(groupID, channel, msg);
		    format(msg,sizeof(msg), "%s has set %s health to %s", user, name, amount);
		    SendClientMessageToAll(0xDDDD2357, msg);
		    SetPlayerHealth(playerid, amount); //Maybe Correct   EDIT: Not working
		}
	}
	return 1;
}

IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new
        	msg[128],
        	playerid
        ;

        if (sscanf(params, "d", playerid)) return 1;
        if (!IsPlayerConnected(playerid)) return 1;

        format(msg, sizeof(msg), "Name: %s | IP: %s | Score: %d | Ping: %i | Health: %i | Armour: %i ", GetPlayerName(playerid), GetPlayerIp(playerid), //Line 508
        GetPlayerScore(playerid), GetPlayerPing(playerid), GetPlayerHealth(playerid), GetPlayerArmour(playerid));
        IRC_GroupSay(groupID, channel, msg);
    }
    return 1;
}
IRCCMD:force(botid, channel[], user[], host[], params[])
{
	if (IRC_IsVoice(botid, channel, user))
	{
	    new tmp[64], playerid, reason;
		if (!IsPlayerConnected(playerid)
		{
                    new msg[128];
		    format(msg, sizeof(msg), "%s has been forced to go into class selection screen by admin %s | Reason: %s" playerid, user, reason); //Line 521
		    IRC_GroupSay(groupID, channel, msg);
		    SendClientMessageToAll(0xDDDD2357, msg);
			ForceClassSelection(playerid);
		}
	}
	return 1;
}
The sethealth command shows messages in-game, but doesn't set the player health to the specific amount.
The getinfo command is working fine, there's just some warning that's bothering me
The force command can't be compiled, idk what's wrong there :l

this is the error messages:
Код:
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(477) : warning 204: symbol is assigned a value that is never used: "tmp"
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508 -- 509) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(508 -- 509) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(520) : error 001: expected token: ")", but found "{"
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : error 001: expected token: "-string end-", but found "-identifier-"
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : warning 215: expression has no effect
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : warning 215: expression has no effect
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : warning 215: expression has no effect
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : error 001: expected token: ";", but found ")"
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : error 029: invalid expression, assumed zero
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(522) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Also, i need explanation about commands... i mean like "/sethealth 0 3" , i want to know how can i assign 0 as the player ID, and the 3 as amount. The thing i did in my command was just copy, paste, and edit :l (or easiest way to create a command)
Reply
#2

Код:
IRCCMD:sethealth(botid, channel[], user[], host[], params[])
{
	if (IRC_IsVoice(botid, channel, user))
	{
	    new playerid, Float:amount; //Line 477
	    if (sscanf(params, "uf", playerid, amount)) return 1;
	if (IsPlayerConnected(playerid))
		{
		    new msg[128], name[MAX_PLAYER_NAME];
		    GetPlayerName(playerid, name, sizeof(name));
		    format(msg, sizeof(msg), "%s has set %s health to %.2f", user, name, amount);
		    IRC_GroupSay(groupID, channel, msg);
		    format(msg,sizeof(msg), "%s has set %s health to %.2f", user, name, amount);
		    SendClientMessageToAll(0xDDDD2357, msg);
		    SetPlayerHealth(playerid, amount); //Maybe Correct   EDIT: Not working
		}
	}
	return 1;
}
This should work, what I've done is switched the amount variable to a float instead of a string, since health and armor values are handled in floats.
Also changed the d inside the sscanf to a 'u', which allows to select playerids by either their id or part of their name.
Reply
#3

Quote:
Originally Posted by oliverrud
Посмотреть сообщение
Код:
IRCCMD:sethealth(botid, channel[], user[], host[], params[])
{
	if (IRC_IsVoice(botid, channel, user))
	{
	    new playerid, Float:amount; //Line 477
	    if (sscanf(params, "uf", playerid, amount)) return 1;
	if (IsPlayerConnected(playerid))
		{
		    new msg[128], name[MAX_PLAYER_NAME];
		    GetPlayerName(playerid, name, sizeof(name));
		    format(msg, sizeof(msg), "%s has set %s health to %.2f", user, name, amount);
		    IRC_GroupSay(groupID, channel, msg);
		    format(msg,sizeof(msg), "%s has set %s health to %.2f", user, name, amount);
		    SendClientMessageToAll(0xDDDD2357, msg);
		    SetPlayerHealth(playerid, amount); //Maybe Correct   EDIT: Not working
		}
	}
	return 1;
}
This should work, what I've done is switched the amount variable to a float instead of a string, since health and armor values are handled in floats.
Also changed the d inside the sscanf to a 'u', which allows to select playerids by either their id or part of their name.
Worked, btw, what does the "u" inside the sscanf means? i thought that was only a message when they didn't put a reason or amount.....

Thanks for your help
Reply
#4

"u" allows you to type the playerid, playername or part of his name.
Reply
#5

Okay
So what about the rest of the errors?
Reply
#6

Quote:
Originally Posted by YahyaBR
Посмотреть сообщение
Worked, btw, what does the "u" inside the sscanf means? i thought that was only a message when they didn't put a reason or amount.....

Thanks for your help
I wrote what it does if you read my whole reply.

And what about the other errors?
You apply the same logic you/i just used for the sethealth thing on the other pieces of code and it should sort itself.
Reply
#7

Quote:
Originally Posted by YahyaBR
Посмотреть сообщение
Okay
So what about the rest of the errors?
pawn Код:
stock GetName(playerid)
{
    new name[64];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[256], playerid;
        if(sscanf(params, "u", playerid)) return 1;
        if(!IsPlayerConnected(playerid)) return 1;
        format(msg, sizeof(msg), "Name: %s | IP: %s | Score: %d | Ping: %i | Health: %.2f | Armour: %.2f ", GetPlayerName(playerid), GetPlayerIp(playerid),
        GetPlayerScore(playerid), GetPlayerPing(playerid), GetPlayerHealth(playerid), GetPlayerArmour(playerid));
        IRC_GroupSay(groupID, channel, msg);
    }
    return 1;
}
IRCCMD:force(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[128], reason[128],playerid;
        if(sscanf(params, "us[128]", playerid,reason)) return 1;
        if(!IsPlayerConnected(playerid) return 1;
        format(msg, sizeof(msg), "%s has been forced to go into class selection screen by admin %s | Reason: %s" GetName(playerid), user, reason);
        IRC_GroupSay(groupID, channel, msg), SendClientMessageToAll(0xDDDD2357, msg);
        ForceClassSelection(playerid);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Juvanii
Посмотреть сообщение
pawn Код:
stock GetName(playerid)
{
    new name[64];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[256], playerid;
        if(sscanf(params, "u", playerid)) return 1;
        if(!IsPlayerConnected(playerid)) return 1;
        format(msg, sizeof(msg), "Name: %s | IP: %s | Score: %d | Ping: %i | Health: %.2f | Armour: %.2f ", GetPlayerName(playerid), GetPlayerIp(playerid),
        GetPlayerScore(playerid), GetPlayerPing(playerid), GetPlayerHealth(playerid), GetPlayerArmour(playerid));
        IRC_GroupSay(groupID, channel, msg);
    }
    return 1;
}
IRCCMD:force(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[128], reason[128],playerid;
        if(sscanf(params, "us[128]", playerid,reason)) return 1;
        if(!IsPlayerConnected(playerid) return 1;
        format(msg, sizeof(msg), "%s has been forced to go into class selection screen by admin %s | Reason: %s" GetName(playerid), user, reason);
        IRC_GroupSay(groupID, channel, msg), SendClientMessageToAll(0xDDDD2357, msg);
        ForceClassSelection(playerid);
    }
    return 1;
}
wrong this will show errors as you are missing a braket

pawn Код:
IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new
            msg[128],
            playerid,
            name[MAX_PLAYER_NAME],
            Float:health,
            Float:armour,
            ip[16],
            score,
        ;

        if (sscanf(params, "u", playerid)) return 1;
        if (!IsPlayerConnected(playerid)) return 1;
        GetPlayerName(playerid , name , sizeof(name));
        GetPlayerIP(playerid, ip, sizeof(ip));
        GetPlayerHealth(playerid, health);  
        GetPlayerArmour(playerid, armour);
        format(msg, sizeof(msg), "Name: %s | IP: %s | Score: %d | Ping: %i | Health: %i | Armour: %i ",name, ip, GetPlayerScore(playerid), GetPlayerPing(playerid),ping, health, armour); //Line 508
        IRC_GroupSay(groupID, channel, msg);
    }
    return 1;
}

IRCCMD:force(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[128], reason[128],playerid;
        if(sscanf(params, "us[128]", playerid,reason)) return 1;
        if(!IsPlayerConnected(playerid)) return 1;
        format(msg, sizeof(msg), "%s has been forced to go into class selection screen by admin %s | Reason: %s" GetName(playerid), user, reason);
        IRC_GroupSay(groupID, channel, msg), SendClientMessageToAll(0xDDDD2357, msg);
        ForceClassSelection(playerid);
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Namer
Посмотреть сообщение
wrong this will show errors as you are missing a braket

pawn Код:
IRCCMD:getinfo(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new
            msg[128],
            playerid,
            name[MAX_PLAYER_NAME],
            Float:health,
            Float:armour,
            ip[16],
            score,
        ;

        if (sscanf(params, "u", playerid)) return 1;
        if (!IsPlayerConnected(playerid)) return 1;
        GetPlayerName(playerid , name , sizeof(name));
        GetPlayerIP(playerid, ip, sizeof(ip));
        GetPlayerHealth(playerid, health);  
        GetPlayerArmour(playerid, armour);
        format(msg, sizeof(msg), "Name: %s | IP: %s | Score: %d | Ping: %i | Health: %i | Armour: %i ",name, ip, GetPlayerScore(playerid), GetPlayerPing(playerid),ping, health, armour); //Line 508
        IRC_GroupSay(groupID, channel, msg);
    }
    return 1;
}

IRCCMD:force(botid, channel[], user[], host[], params[])
{
    if (IRC_IsVoice(botid, channel, user))
    {
        new msg[128], reason[128],playerid;
        if(sscanf(params, "us[128]", playerid,reason)) return 1;
        if(!IsPlayerConnected(playerid)) return 1;
        format(msg, sizeof(msg), "%s has been forced to go into class selection screen by admin %s | Reason: %s" GetName(playerid), user, reason);
        IRC_GroupSay(groupID, channel, msg), SendClientMessageToAll(0xDDDD2357, msg);
        ForceClassSelection(playerid);
    }
    return 1;
}
Okay, it still have some errors but i managed to fix them.
But now, i still have these warnings, is that ok?
Код:
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(477) : warning 204: symbol is assigned a value that is never used: "tmp"
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(507) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(521) : warning 202: number of arguments does not match definition
E:\Samp Server\SAMP SERVER\filterscripts\irc.pwn(521) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Warnings.
And what if i want to add message "Player not found"? i dont know which line checks for the player ID.


Thanks for all your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)