You cant drag one more than person. (HOW?)
#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


Messages In This Thread
You cant drag one more than person. (HOW?) - by Trynda - 17.05.2014, 05:31
Re: You cant drag one more than person. (HOW?) - by Trynda - 17.05.2014, 06:03
Re: You cant drag one more than person. (HOW?) - by rockhopper - 17.05.2014, 06:04
Re: You cant drag one more than person. (HOW?) - by PierreMarley - 17.05.2014, 06:07
Re: You cant drag one more than person. (HOW?) - by Trynda - 17.05.2014, 06:18
Re: You cant drag one more than person. (HOW?) - by Threshold - 17.05.2014, 08:43
Re: You cant drag one more than person. (HOW?) - by Trynda - 17.05.2014, 13:35
Re: You cant drag one more than person. (HOW?) - by Threshold - 17.05.2014, 13:47

Forum Jump:


Users browsing this thread: 1 Guest(s)