knockout command help
#1

hello, i'm trying to do knockout command, when i try to knockout somone its just knockout id 0, example /knockout 5 it knocksout player id 0, how i can do it?
Код:
CMD:knockout(playerid, params[])
{
    new string[128], targetid, playerb;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /knockout [playerid]");
	if(!IsPlayerLoggedIn(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(!IsPlayerNearPlayer(playerid, targetid, 4)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
    if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command under level 3.");
    if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't knockout yourself.");
	{
    new giveplayername[MAX_PLAYER_NAME];
	GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
	new rands = random(2)+1;
	format(string, sizeof(string), "* %s swings at %s and tries to knock him out.", sendername, giveplayername);
	SendNearbyMessage(playerid, 15, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
    ApplyAnimation(playerid,"FIGHT_D","FightD_3",4.0,0,1,1,0,0);
	TogglePlayerControllable(giveplayerid, 0);
	ApplyAnimation(giveplayerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
	SetTimerEx("ClearKnock", 20000, false, "i", giveplayerid);
	KnockedDown[giveplayerid] = 1;
	format(string, sizeof(string), "* %s succeeds to knock him down.", sendername);
    SendNearbyMessage(playerid, 15, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
	}
     return 1;
}
Reply
#2

pawn Код:
CMD:knockout(playerid, params[])
{
    new string[128], targetid;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /knockout [playerid]");
    if(!IsPlayerLoggedIn(targetid)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(!IsPlayerNearPlayer(playerid, targetid, 4)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
    if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command under level 3.");
    if(playerid == giveplayerid) return SendClientMessage(playerid, COLOR_GREY, "You can't knockout yourself.");
    {
    new giveplayername[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
    new rands = random(2)+1;
    format(string, sizeof(string), "* %s swings at %s and tries to knock him out.", sendername, giveplayername);
    SendNearbyMessage(playerid, 15, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
    ApplyAnimation(playerid,"FIGHT_D","FightD_3",4.0,0,1,1,0,0);
    TogglePlayerControllable(giveplayerid, 0);
    ApplyAnimation(giveplayerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    SetTimerEx("ClearKnock", 20000, false, "i", giveplayerid);
    KnockedDown[giveplayerid] = 1;
    format(string, sizeof(string), "* %s succeeds to knock him down.", sendername);
    SendNearbyMessage(playerid, 15, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
    }
     return 1;
}
Reply
#3

Same
Reply
#4

You were first using playerb, and then you changed to giveplayerid.
giveplayerid was created and never changed from 0 to something else.
Reply
#5

so what i should do?
Reply
#6

Change playerb to giveplayerid or giveplayerid to playerb..
Reply
#7

THANKS +REP ALL !!!!!!!!!!!!!!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)