Kidnapping Help code
#1

I am trying to make a Kidnapping command that puts the kidnapped person in the kidnapper's car. I do not know how to do this, if someone can help me I'd be thankful.
Reply
#2

Use new vid = GetPlayerVehicleID(playerid); and then use PutPlayerInVehicle(targetid, vid);
Reply
#3

pawn Код:
CMD:kidnap(playerid, params [ ] )
{
    new string[128];
    new ID;
    if(sscanf(params, "u", ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /kidnap (Player Name/ID)");
        return 1;
    }

    if(LastVehicle[playerid] == -1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must enter a vehicle before attempting to kidnap a player.");
        return 1;
    }

    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot kidnap them",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 4)
    {
        format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to kidnap him.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap someone while in a vehicle. Exit the vehicle first.");
        return 1;
    }
    if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap someone while they are in a vehicle. Get them to exit the vehicle first.");
        return 1;
    }
    if(playerid == ID)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot kidnap yourself, how can you even manage that?");
        return 1;
    }

    new crand = random(100);
    if(crand <= 20)
    {
        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] =600;

        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;
}
And under onplayerstatechange
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != VEHICLE_PARAMS_ON && IsACycleBike(vid))
        {
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        LastVehicle[playerid] =GetPlayerVehicleID(playerid);
    }
Reply
#4

Why do you copy stuff from your gamemode and post them here?
A lot of the stuff you're using are user created functions and variables, not sa-mp natives.
Reply
#5

Код:
CMD:putinveh(playerid, params[])
{
//KidnapVehicle

		new id, s[128],vid;
		if(vid < 0) return SendClientMessage(playerid, -1, "Enter a Vehicle");
		vid = GetPlayerVehicleID(playerid);
		//TogglePlayerControllable(id,1);
		PutPlayerInVehicle(id,vid,1);
		
		//TogglePlayerControllable(id,0);
		format(s, sizeof(s), "You put %d in a Vehicle you drove last, I hope, idk", GetName(id));
		SendClientMessage(playerid, -1, s);
		
return 1;
}
this is what i got now(Pretty tired), and well it's buggy.

It teleports me into the vehicle only when I sit in it. The rest of the kidnap command I have somewhere i just need to modify it.
Reply
#6

Bump


https://www.youtube.com/watch?v=V7D-...ature=*********
Reply
#7

BUMP
Reply
#8

Bumping up.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)