[Help] Kill command.
#1

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

GetPlayerName(playerid,PlayerName, sizeof(PlayerName));
Reply
#3

This didn't helped me ! Still the same error
Reply
#4

Код:
	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 .
Reply
#5

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];
Reply
#6

Because you have two strings.
Reply
#7

Just delete the string[100];
Reply
#8

Ok tks a lot man .Really helped . Respect !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)