SA-MP Forums Archive
[Help] Kill command. - 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: [Help] Kill command. (/showthread.php?tid=194988)



[Help] Kill command. - [Aka]Dragonu - 01.12.2010

Hi. My kill command makes an error . I wanna make it when you tipe /kill , to appear the message to all the server like : Dragonu has killed himself.

Here's the code :
Код:
	if (strcmp(cmd, "/kill", true) == 0)
	{
	    if(PlayerInfo[playerid][pJailedSec] > 0)
		{
			SendClientMessage(playerid, COLOR_RED, "You cannot kill yourself if you're in the jail.");
		}
		else
		{
			SetPlayerHealth(playerid, 0);
			GetPlayerName(playerid,PlayerName, sizeof(sendername2));
	        format(string,sizeof(string),".: %s Has killed himself (/kill) :.",PlayerName);
	        SendClientMessageToAll(COLOR_RED,string);
		}
		return 1;
	}
And this is the error :
Код:
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(7757) : error 048: array dimensions do not match
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
This is the line 7757 :
Код:
GetPlayerName(playerid,PlayerName, sizeof(sendername2));



Re: [Help] Kill command. - BMUK - 01.12.2010

GetPlayerName(playerid,PlayerName, sizeof(PlayerName));


Re: [Help] Kill command. - [Aka]Dragonu - 01.12.2010

This didn't helped me ! Still the same error


Re: [Help] Kill command. - Haydz - 01.12.2010

Код:
	if (strcmp(cmd, "/kill", true) == 0)
	{
	    if(PlayerInfo[playerid][pJailedSec] > 0)
		{
			SendClientMessage(playerid, COLOR_RED, "You cannot kill yourself if you're in the jail.");
		}
		else
		{
		 SetPlayerHealth(playerid, 0);
		 new pname[24];
                 new string[100];
                 GetPlayerName(playerid,pname,24);
                 format(string,sizeof(string), "%s has killed them self!",pname);
                 SendClientMessageToAll(COLOR_RED,string);
		}
		return 1;
	}
Something like that should work hopefully .


Re: [Help] Kill command. - [Aka]Dragonu - 01.12.2010

It works but i got this warning
pawn Код:
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(7758) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
At this line :
pawn Код:
new string[100];



Re: [Help] Kill command. - WillyP - 01.12.2010

Because you have two strings.


Re: [Help] Kill command. - BMUK - 01.12.2010

Just delete the string[100];


Re: [Help] Kill command. - [Aka]Dragonu - 01.12.2010

Ok tks a lot man .Really helped . Respect !