/kidnap and /detain bug
#2

Try this one
pawn Код:
dcmd_kidnap(playerid,params[])
{
    new string[128],ID,crand = random(100);
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /kidnap (Player Name/ID)");
    if(IsSpawned[playerid] != 1) return SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
    if(IsFrozen[playerid] == 1) return SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
    if(LastVehicle[playerid] == 0) return SendClientMessage(playerid,COLOR_ERROR,"You must enter a vehicle before attempting to kidnap a player.");
    if(InAdminMode[ID] == 1) return SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
    if(IsKidnapped[playerid] == 1)return SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
    if(IsKidnapped[ID] == 1) return SendClientMessage(playerid,COLOR_ERROR,"They are kidnapped. You cannot kidnap them twice.");
    if(gTeam[playerid] != TEAM_KIDNAP)return SendClientMessage(playerid,COLOR_ERROR,"Only kidnappers can use this command to kidnap players.");
    if(!IsPlayerConnected(ID)) return SendClientMessageEx(playerid,COLOR_ERROR,"The player ID (%d) is not connected to the server. You cannot kidnap them",ID);
    if(GetDistanceBetweenPlayers(playerid,ID) > 4) return SendClientMessageEx(playerid,COLOR_ERROR,"%s(%d) is too far away. You cannot reach him to kidnap him.",PlayerName(ID),ID);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)return SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap someone while in a vehicle. Exit the vehicle first.");
    if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER) return  SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap someone while they are in a vehicle. Get them to exit the vehicle first.");
    if(playerid == ID) return SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap yourself, how can you even manage that?");
    if(IsSpawned[ID] != 1) return SendClientMessageEx(playerid,COLOR_ERROR,"%s(%d) is not spawned. You cannot kidnap dead people ..",PlayerName(ID),ID);
    if(IsFrozen[ID] == 1) SendClientMessageEx(playerid,COLOR_ERROR,"%s(%d) is frozen by a Server Administrator. You cannot kidnap them.",PlayerName(ID),ID);
    if(AttemptedToKidnapRecently[playerid] >= 1) return SendClientMessage(playerid,COLOR_ERROR,"You are tired from your last kidnap attempt. Please wait before trying to kidnap again.");
    if(HasKidnappedRecently[playerid] >= 1) return SendClientMessage(playerid,COLOR_ERROR,"You are tired from your last kidnap. Please wait before kidnapping someone again.");
    if(HasRope[playerid] == 0) return SendClientMessage(playerid,COLOR_ERROR,"You must have rope in order to use this command. Buy one from Supa Save.");
    if(crand <= 30)
    {
        SendClientMessage(playerid,COLOR_ERROR,"Kidnap attempt failed. The player slipped out of your grasp.");
        AttemptedToKidnapRecently[playerid] =60;
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 30)
    {
        new current_zone = player_zone[playerid];

        SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Kidnapped Player_]]");
        format(string,sizeof(string),"You have grabbed %s(%d), tied them up with your rope and thrown them into your vehicle.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_RED,string);
        IncreaseWantedLevel(playerid,8);
        HasKidnappedRecently[playerid] =300;
        HasRope[playerid] --;
        IncreasePlayerScore(playerid,3);

        SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Kidnapped_]]");
        format(string,sizeof(string),"%s(%d) has tied you up and thrown you into their vehicle!. If you have scissors you can /cutrope.",PlayerName(playerid),playerid);
        SendClientMessage(ID,COLOR_RED,string);
        PutPlayerInVehicle(ID,LastVehicle[playerid],1);
        TogglePlayerControllable(ID,0);
        IsKidnapped[ID] =120;

        format(string,sizeof(string),"[KIDNAP] %s(%d) has tied %s(%d) up and thrown them into their vehicle!",PlayerName(playerid),playerid,PlayerName(ID),ID);
        SendClientMessageToAll(COLOR_RED,string);

        format(string,sizeof(string),"[POLICE RADIO] %s(%d) has tied %s(%d) up with rope and thrown them into their vehicle! Location: %s",PlayerName(playerid),playerid,PlayerName(ID),ID,zones[current_zone][zone_name]);
        SendClientMessageToAllCops(string);
        return 1;
    }
    return 1;
}
Also to don`t forgot this is define for SendClientMessageEx
pawn Код:
#define SendClientMessageEx(%0,%1,%2,%3)\
        do{\
            format(str,sizeof(str),%2,%3);\
            SendClientMessage(%0,%1,str);\
        }\
        while(False)
//----------------------------------------
#define SendClientMessageToAllEx(%0,%1,%2)\
        do{\
            format(str,sizeof(str),%1,%2);\
            SendClientMessageToAll(%0,str);\
        }\
        while(False)
You must put it to work without errors!
Reply


Messages In This Thread
/kidnap and /detain bug - by Patrick - 12.01.2013, 09:30
Re: /kidnap and /detain bug - by Sanady - 12.01.2013, 11:08

Forum Jump:


Users browsing this thread: 1 Guest(s)