You cant drag one more than person. (HOW?)
#1

hi,

I want to add here "You cant drag more than one person" but how ?

Код:
CMD:drag(playerid, params[])
{
        new id, string[26+MAX_PLAYER_NAME], string2[20+MAX_PLAYER_NAME];
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GRAD1, "CMD:/drag [playerid]");
        if(PlayerCuffed[id] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "This player must first be cuffed");
        if(PlayerCuffed[id] == 1)
			return SendClientMessage(playerid, COLOR_GREY, "You can't drag a tazed player.");
        if(!IsPlayerConnected(id))
			return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");

		if(GetDistanceBetweenPlayers(id, playerid) > 4)
			return SendClientMessage(playerid, COLOR_GREY, "You're not close enough to the player!");

		if(PlayerCuffed[id] == 0)
			return SendClientMessage(playerid, COLOR_GREY, "That person isn't cuffed.");

		if(PlayerCuffed[id] == 1)
			return SendClientMessage(playerid, COLOR_GREY, "You can't drag a tazed player.");

		if(id == playerid)
			return SendClientMessage(playerid, COLOR_GREY, "You can't restrain yourself!");

		if(GetPlayerState(id) != PLAYER_STATE_ONFOOT)
			return SendClientMessage(playerid, COLOR_GREY, "That person is in a car - get them out first.");

		if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT)
			return SendClientMessage(playerid, COLOR_GREY, "You're in a car - get out first.");

		if(GetPVarInt(playerid, "PBM") > 0)
			return SendClientMessage(playerid, COLOR_WHITE, "You're not able to do this while in a paintball game.");

		if(GetPVarInt(playerid, "EventToken") != 0)
			return SendClientMessage(playerid, COLOR_GREY, "You can't use the tazer while you're in an event.");

		if(PlayerCuffedTime[playerid] > 0)
			return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");

		if(GetPVarInt(playerid, "Injured") == 1)
			return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");

		if(PlayerInfo[playerid][pJailed] > 0)
			return SendClientMessage(playerid, COLOR_WHITE, "You can't use this in jail/prison.");

		if(PlayerCuffed[playerid] >= 1)
			return SendClientMessage(playerid, COLOR_WHITE, "You can't use this while tazed/cuffed.");

		if(GetPVarInt(id, "Injured") == 1)
			return SendClientMessage(playerid, COLOR_GREY, "You can't cuff injured people.");
			
        if(Dragged[id] == 0 && Dragging[playerid] == 0)
        {


            format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			
            Dragged[id] = 1;
            Dragging[playerid] = 1;
            format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
            format(string2, sizeof(string2), " You are dragging %s.", RemoveUnderScore(id));
            SendClientMessage(playerid, COLOR_PURPLE, string2);
            SendClientMessage(id, COLOR_PURPLE, string);
        	draggedtimer[id] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,id);
        }
        else
        {
            format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			
            Dragged[id] = 0;
            Dragging[playerid] = 0;
            SendClientMessage(playerid, COLOR_PURPLE, "You have stopped dragging your target.");
            SendClientMessage(id, COLOR_PURPLE, "You aren't being dragged anymore.");
            KillTimer(draggedtimer[id]);
        }
        return 1;
}
THANKS IN ADVANCE!!!!!!!!!!!!!!!!!!!
Reply
#2

howsssss
Reply
#3

Please explain a little more
Reply
#4

use this none bugs
Код:
CMD:drag(playerid, params[])
{
	if(IsACop(playerid))
	{
		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
			{
				if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
				if(GetPVarInt(giveplayerid, "BeingDragged") == 1)
				{
					SendClientMessageEx(playerid, COLOR_WHITE, " That person is already being dragged. ");
					return 1;
				}
                new Float:dX, Float:dY, Float:dZ;
				GetPlayerPos(giveplayerid, dX, dY, dZ);
				if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
					return 1;
				}
				format(string, sizeof(string), "* %s is now dragging you.", GetPlayerNameEx(playerid));
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
				SendClientMessageEx(playerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* %s grabs ahold of %s and begins to move them.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessageEx(playerid, COLOR_WHITE, "You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
				SetPVarInt(giveplayerid, "BeingDragged", 1);
				SetPVarInt(playerid, "DraggingPlayer", giveplayerid);
				SetTimerEx("DragPlayer", 1000, 0, "ii", playerid, giveplayerid);
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_WHITE, " The specified person is not cuffed !");
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You are not a Law Enforcement Official!");
		return 1;
	}
	return 1;
}
Enjoy
Reply
#5

Quote:
Originally Posted by PierreMarley
Посмотреть сообщение
use this none bugs
Код:
CMD:drag(playerid, params[])
{
	if(IsACop(playerid))
	{
		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
			{
				if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
				if(GetPVarInt(giveplayerid, "BeingDragged") == 1)
				{
					SendClientMessageEx(playerid, COLOR_WHITE, " That person is already being dragged. ");
					return 1;
				}
                new Float:dX, Float:dY, Float:dZ;
				GetPlayerPos(giveplayerid, dX, dY, dZ);
				if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
					return 1;
				}
				format(string, sizeof(string), "* %s is now dragging you.", GetPlayerNameEx(playerid));
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
				SendClientMessageEx(playerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* %s grabs ahold of %s and begins to move them.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessageEx(playerid, COLOR_WHITE, "You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
				SetPVarInt(giveplayerid, "BeingDragged", 1);
				SetPVarInt(playerid, "DraggingPlayer", giveplayerid);
				SetTimerEx("DragPlayer", 1000, 0, "ii", playerid, giveplayerid);
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_WHITE, " The specified person is not cuffed !");
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You are not a Law Enforcement Official!");
		return 1;
	}
	return 1;
}
Enjoy
THAAAAAAAANKSS, Can you please explain what is VarInt ?
Reply
#6

Apart from copying my own code into this thread, I've fixed up yours a little bit. (Damn it's messy though...)

This should work:
pawn Код:
CMD:drag(playerid, params[])
{
    if(GetPVarInt(playerid, "PBM") > 0) return SendClientMessage(playerid, COLOR_WHITE, "You're not able to do this while in a paintball game.");
    if(GetPVarInt(playerid, "EventToken") != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't use the tazer while you're in an event.");
    if(PlayerCuffedTime[playerid] > 0) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
    if(GetPVarInt(playerid, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
    if(PlayerInfo[playerid][pJailed] > 0) return SendClientMessage(playerid, COLOR_WHITE, "You can't use this in jail/prison.");
    if(PlayerCuffed[playerid] >= 1) return SendClientMessage(playerid, COLOR_WHITE, "You can't use this while tazed/cuffed.");
    if(Dragging[playerid] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "You can't drag more than one person at a time!");
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You're in a car - get out first.");
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GRAD1, "CMD:/drag [playerid]");
    if(id == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't restrain yourself!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");
    if(PlayerCuffed[id] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "This player must first be cuffed");
    //PlayerCuffed? Don't you mean PlayerTazed or something?
    //if(PlayerCuffed[id] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't drag a tazed player.");
    if(GetDistanceBetweenPlayers(id, playerid) > 4) return SendClientMessage(playerid, COLOR_GREY, "You're not close enough to the player!");
    if(GetPlayerState(id) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "That person is in a car - get them out first.");
    if(GetPVarInt(id, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't cuff injured people.");
    new string[90];
    if(!Dragged[id] && !Dragging[playerid])
    {
        format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        Dragged[id] = 1;
        Dragging[playerid] = id;
        format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
        SendClientMessage(id, COLOR_PURPLE, string);
        format(string, sizeof(string), " You are dragging %s.", RemoveUnderScore(id));
        SendClientMessage(playerid, COLOR_PURPLE, string);
        draggedtimer[id] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,id);
    }
    else
    {
        format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        Dragged[id] = 0;
        Dragging[playerid] = INVALID_PLAYER_ID;
        SendClientMessage(playerid, COLOR_PURPLE, "You have stopped dragging your target.");
        SendClientMessage(id, COLOR_PURPLE, "You aren't being dragged anymore.");
        KillTimer(draggedtimer[id]);
    }
    return 1;
}
What I did is assign the player id of the person I am already dragging to a variable, and if the id I enter is not the same as the person I am already dragging, it will stop the code and send an error message.
Reply
#7

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Apart from copying my own code into this thread, I've fixed up yours a little bit. (Damn it's messy though...)

This should work:
pawn Код:
CMD:drag(playerid, params[])
{
    if(GetPVarInt(playerid, "PBM") > 0) return SendClientMessage(playerid, COLOR_WHITE, "You're not able to do this while in a paintball game.");
    if(GetPVarInt(playerid, "EventToken") != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't use the tazer while you're in an event.");
    if(PlayerCuffedTime[playerid] > 0) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
    if(GetPVarInt(playerid, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
    if(PlayerInfo[playerid][pJailed] > 0) return SendClientMessage(playerid, COLOR_WHITE, "You can't use this in jail/prison.");
    if(PlayerCuffed[playerid] >= 1) return SendClientMessage(playerid, COLOR_WHITE, "You can't use this while tazed/cuffed.");
    if(Dragging[playerid] != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "You can't drag more than one person at a time!");
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You're in a car - get out first.");
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GRAD1, "CMD:/drag [playerid]");
    if(id == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't restrain yourself!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");
    if(PlayerCuffed[id] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "This player must first be cuffed");
    //PlayerCuffed? Don't you mean PlayerTazed or something?
    //if(PlayerCuffed[id] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't drag a tazed player.");
    if(GetDistanceBetweenPlayers(id, playerid) > 4) return SendClientMessage(playerid, COLOR_GREY, "You're not close enough to the player!");
    if(GetPlayerState(id) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "That person is in a car - get them out first.");
    if(GetPVarInt(id, "Injured") == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't cuff injured people.");
    new string[90];
    if(!Dragged[id] && !Dragging[playerid])
    {
        format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        Dragged[id] = 1;
        Dragging[playerid] = id;
        format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
        SendClientMessage(id, COLOR_PURPLE, string);
        format(string, sizeof(string), " You are dragging %s.", RemoveUnderScore(id));
        SendClientMessage(playerid, COLOR_PURPLE, string);
        draggedtimer[id] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,id);
    }
    else
    {
        format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        Dragged[id] = 0;
        Dragging[playerid] = INVALID_PLAYER_ID;
        SendClientMessage(playerid, COLOR_PURPLE, "You have stopped dragging your target.");
        SendClientMessage(id, COLOR_PURPLE, "You aren't being dragged anymore.");
        KillTimer(draggedtimer[id]);
    }
    return 1;
}
What I did is assign the player id of the person I am already dragging to a variable, and if the id I enter is not the same as the person I am already dragging, it will stop the code and send an error message.
a variable like new dragging[MAX_PLAYERS]; is same at VarInt ?

What is the help of VarInt and there is new vars
Reply
#8

You can make it the same, but PVars are not as efficient in this circumstance. Creating hundreds of PVars can just get messy. This way, you can keep track of what you're dealing with.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)