SA-MP Forums Archive
IRC Scripting help - 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: IRC Scripting help (/showthread.php?tid=213801)



IRC Scripting help - [Ask]G_Sk8er - 19.01.2011

hello

I was putting 2 new codes in my script (!score and !fakemsg)

Both give same bug: It says invalid ID while the player with that ID is connected
Код:
[Ask]Sk8er> !ping 1
<Shizzle>  [Ask]Sk8er's ping is 42
<[Ask]Sk8er> !fakemsg 1 fu
<Shizzle> Error: Invalid player ID.
Here are the command codes:

Код:
irccmd_score(conn, channel[], user[], params[])
{
    if(!ircIsVop(conn,channel,user)) return AccessDenied(user);
    
    new ID = strval(params), PlayerName[24], tString[256], PlayerScore[24];
	if(sscanf(params,"s",ID))return ircSay(conn,channel,"3Usage:1 !score <PartOfName/PlayerID>");
	if(!IsPlayerConnected(ID))return ircSay(conn,channel,"4*** Error: Invalid player ID.");
	format(tString,sizeof(tString),"3* Score from %s: %d",PlayerName,ID,PlayerScore);
	GetPlayerScore(ID);
	ircSay(BotSwitcher(),channel,tString);
 	#pragma unused conn, user
	return true;
}

irccmd_fakemsg(conn, channel[], user[], params[])
{
    if(!ircIsOp(conn,channel,user)) return AccessDenied(user);
    
	new ID = strval(params),tString[128], PlayerName[24], msg[100];
	GetPlayerName(ID, PlayerName, sizeof(PlayerName));
 	if(sscanf(params,"ss",ID,msg)) return ircSay(conn,channel,"3Usage:1 !fakemsg <PartOfName/PlayerID> <Message>");
	if(!IsPlayerConnected(ID))return ircSay(conn,channel,"5Error: Invalid player ID.");
	SendPlayerMessageToAll(ID,msg);
	format(tString,sizeof(tString),"[%d] 07%s: %s",ID,PlayerName,msg);
	ircSay(BotSwitcher(),channel,tString);
	#pragma unused user,conn
   	return true;
}
Some1 can help meh?


Re: IRC Scripting help - hoodline - 20.01.2011

why are you doing ID = strval(params)

ID is stored in there from sscanf take strval(params) from ID

also put GetPlayerName after it checks if the player is connected


Re: IRC Scripting help - Infamous - 20.01.2011

Also you don't need to check if the player is connected as sscanf does that for you.

use this instead:

pawn Код:
if(ID == INVALID_PLAYER_ID)
    return ircsay(conn, channel, "4*** Error: Invalid player ID.");



Re: IRC Scripting help - [Ask]G_Sk8er - 20.01.2011

Resolved, plz lock :P