/slap command
#1

hello every one
i think this command is fine but Error come from no where xD

Code is
Код:
COMMAND:slap(playerid, params[])
{
	new string[208 + MAX_PLAYER_NAME],PlayerN[MAX_PLAYERS],OtherN[MAX_PLAYERS];
    new Float:x, Float:y, Float:z;
	if(AccountInfo[playerid][AdminLevel] >= 1)
	{
	new targetid,String[156];
	if(sscanf(params,"us", targetid,String)) return SendClientMessage(playerid, COLOR_WHITE, ""WHITE"Usage: "GREEN"/slap "WHITE"[playerid] [REASON]");
	if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You Can't Slap Yourself !");
	if(AccountInfo[playerid][AdminLevel] < AccountInfo[playerid][AdminLevel]) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't use this command on A Higher Level Admin Then You!");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid PlayerID"RED"(Player Not Connected)!");
	if(String[0] <= 4) return SendClientMessage(playerid, COLOR_RED, "Your Reason Needs To Be More Than 4 Characters");
	GetPlayerName(playerid,PlayerN,sizeof(PlayerN));
	GetPlayerName(targetid,OtherN,sizeof(OtherN));
	GetPlayerPos(OtherN,x,y,z);
	SetPlayerPos(OtherN,z,y,z +5);
	format(string, sizeof(string), ""BLUE"\"%s\""RED" Was Slaped By Admin "BLUE"\"%s\""RED" Reason: %s", OtherN, PlayerN,String);
	SendClientMessageToAll(COLOR_BRIGHTRED, string);
	printf("\"%s\"Was Slapped By Admin \"%s\" Reason %s",OtherN, PlayerN,String);
	
	}
	else
	{
	SendClientMessage(playerid,COLOE_WHITE,"You Are Not Hight Enough level to use this Command");
	}
	return 1;
}
Erros Show:
Код:
C:\Users\almooo\Desktop\Zombe server test\gamemodes\Zm.pwn(2731) : error 035: argument type mismatch (argument 1)
C:\Users\almooo\Desktop\Zombe server test\gamemodes\Zm.pwn(2732) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Please Help me in Dat
Reply
#2

any ?
Reply
#3

show as error line
Reply
#4

the lines are
Код:
GetPlayerPos(OtherN,x,y,z);
	SetPlayerPos(OtherN,z,y,z +5);
Reply
#5

pawn Код:
COMMAND:slap(playerid, params[])
{
    new string[208 + MAX_PLAYER_NAME],PlayerN[MAX_PLAYER_NAME],OtherN[MAX_PLAYER_NAME];
    new Float:x, Float:y, Float:z;
    if(AccountInfo[playerid][AdminLevel] >= 1)
    {
        new targetid,String[156];
        if(sscanf(params,"us", targetid,String)) return SendClientMessage(playerid, COLOR_WHITE, ""WHITE"Usage: "GREEN"/slap "WHITE"[playerid] [REASON]");
        if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You Can't Slap Yourself !");
        if(AccountInfo[playerid][AdminLevel] < AccountInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't use this command on A Higher Level Admin Then You!");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid PlayerID"RED"(Player Not Connected)!");
        if(String <= 4) return SendClientMessage(playerid, COLOR_RED, "Your Reason Needs To Be More Than 4 Characters");
        GetPlayerName(playerid,PlayerN,sizeof(PlayerN));
        GetPlayerName(targetid,OtherN,sizeof(OtherN));
        GetPlayerPos(OtherN,x,y,z);
        SetPlayerPos(OtherN,z,y,z +5);
        format(string, sizeof(string), ""BLUE"\"%s\""RED" Was Slaped By Admin "BLUE"\"%s\""RED" Reason: %s", OtherN, PlayerN,String);
        SendClientMessageToAll(COLOR_BRIGHTRED, string);
        printf("\"%s\"Was Slapped By Admin \"%s\" Reason %s",OtherN, PlayerN,String);
    }
    else
    {
        SendClientMessage(playerid,COLOE_WHITE,"You Are Not Hight Enough level to use this Command");
    }
    return 1;
}
Could it be because of these?

pawn Код:
if(AccountInfo[playerid][AdminLevel] < AccountInfo[playerid][AdminLevel]) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't use this command on A Higher Level Admin Then You!");

//and

if(String[0] <= 4) return SendClientMessage(playerid, COLOR_RED, "Your Reason Needs To Be More Than 4 Characters");
Why would you check if your admin level is lower then your admin level? Changed the playerid to a targetid.

And not positive, haven't scripted in a while, but why would you write String[0] if the string length is already defined.

Plus, you made the player/target name variables [MAX_PLAYERS] when it should be [MAX_PLAYER_NAME] I presume.

EDIT: Just saw your new post, it should be:

pawn Код:
GetPlayerPos(targetid,x,y,z);
SetPlayerPos(targetid,z,y,z +5);
Why would you place a name in there?
Reply
#6

Try This

Код:
CMD:slapid(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >=4)
	{
		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /slapid [playerid]");

		new Float:shealth;
		new Float:slx, Float:sly, Float:slz;

		if(IsPlayerConnected(giveplayerid))
		{

			GetPlayerHealth(giveplayerid, shealth);
			SetPlayerHealth(giveplayerid, shealth-5);
			GetPlayerPos(giveplayerid, slx, sly, slz);
			SetPlayerPos(giveplayerid, slx, sly, slz+5);
			PlayerPlaySound(giveplayerid, 1130, slx, sly, slz+5);
			format(string, sizeof(string), "AdmCmd: %s was slapped by %s",GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid));
			ABroadCast(COLOR_LIGHTRED,string,2);

		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#7

Use this...
pawn Код:
CMD:slap(playerid, params[])
{
    if(AccountInfo[playerid][AdminLevel] >= 1)
    {
        new id;
        if(!sscanf(params, "u", id))
        {
            new Name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], string[128], Float:px, Float:py, Float:pz;
            GetPlayerName(playerid, Name, sizeof(Name));
            GetPlayerName(id, PlayerName, sizeof(PlayerName));
            GetPlayerPos(id, px, py, pz);
            SetPlayerPos(playerid, px, py, pz+10);
            format(string, sizeof(string), "You have been slapped by administrator %s.", Name);
            SendClientMessage(id, 0xFFFFFFFF, string);
            format(string, sizeof(string), "You slapped %s.", PlayerName);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
            return 1;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /slap [PlayerId/PartOfName]");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not alowed to use this command.");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)