Kidnapp, PlayerInVehicle
#1

Hi Guyz,

I'm here again
A little doubt.

I'm making a /kidnapp command, but I want to do:

When the player who will kidnapp someone type /kidnapp, the player who will be kidnapp, have to be as passenger in the same vehicle as the kidnapper.

So, how I do?

PS: I'm using strcmp.
Reply
#2

well in lot rp mods u have script for /tie some1, works in exacly same way as you explained here, mybe you shall check that
Reply
#3

PutPlayerInVehicle(playerid,seat);

seat 1 - driver
seat 2 - co-driver
seat 3 - passenger
seat 4 - passenger [ if the car got more than 2 places ]
Reply
#4

I'm not sure but I think you want to put someone in your vehicle o_O.
Sorry i used dcmd for this but I think it should work:
pawn Код:
if(strcmp(cmdtext, "/kidnap", true) == 0)
{
    new id, index, name[24], string[256], tmp[256], tmp2[256];

    tmp = strtok(cmdtext, index);
    tmp2 = strtok(cmdtext, index);

    if(!strlen(tmp) || !strlen(tmp2))
      return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /putin PLAYERID/NAME SEATID");

    if(strval(tmp) == playerid) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You cannot put yourself in your own car!");

    if(IsPlayerConnected(id) && !IsPlayerInAnyVehicle(id) && id != INVALID_PLAYER_ID && id != playerid)
    {
      if(IsNumeric(tmp)) id = ReturnPlayerID(tmp);
      else id = strval(tmp);

        PutPlayerInVehicle(id, GetPlayerVehicleID(playerid), strval(tmp2));

        if(!IsNumeric(tmp2))
          return SendClientMessage(playerid, COLOR_RED, "[ERROR]: The seatid should be a number!");

        if(!IsPlayerInAnyVehicle(playerid))
          return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You should be in a vehicle!");

        if(IsPlayerInAnyVehicle(id))
          return SendClientMessage(playerid, COLOR_RED, "[ERROR]: The target should be in a vehicle!");

        GetPlayerName(id, name, 24);
        format(string, 256, "[SUCCES]: You have put %s in your vehicle on seatid %d", name, strval(tmp));
        SendClientMessage(playerid, COLOR_GREEN, string);
    }

    else return SendClientMessage(playerid, COLOR_RED, "[ERROR]: If the target is a disconnected player you cannot put him in your car!");

    return 1;
}
Sorry, it's not fully working but I hope this is what you want.
You need the strtok function to work...
Reply
#5

I THINK he means the ability to kidnap someone if they're in your car. You'll need strtok for this:

pawn Код:
if(strcmp(cmd, "/kidnap", true) == 0)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000, "You must be in a vehicle to kidnap someone!");
    new KidnapID = strval(strtok(cmd, idx));
    if(!IsPlayerConnected(KidnapID) || IsNumeric(cmdtext)) return SendClientMessage(playerid, 0xFF0000, "That's an invalid ID.");
    if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000, "That player isn't in your car.");
    if(random(10) == 1)
    new PName[MAX_PLAYER_NAME];
    new KidnapString[40];
    {
        SendClientMessage(playerid, 0xFFFF00, "The kidnap was successful.");
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "%s has kidnapped you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    else
    {
        GetPlayerName(KidnapID, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), The kidnap failed and %s noticed you tried to kidnap him!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "
%s has attempted to kidnap you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);   
    }
    return 1;
}
There's a 1/10 chance you'll successfully kidnap.
Reply
#6

Oh, God.
You guyz are really nice!

It's like Ghett0 did. Not put a player in a car, and kidnapp with a player in a car.
I trought that I have to use strtok

Thanks, I'll check.

Thanks a lot!
Reply
#7

Quote:
Originally Posted by Ghett0
I THINK he means the ability to kidnap someone if they're in your car. You'll need strtok for this:

pawn Код:
if(strcmp(cmd, "/kidnap", true) == 0)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000, "You must be in a vehicle to kidnap someone!");
    new KidnapID = strval(strtok(cmd, idx));
    if(!IsPlayerConnected(KidnapID) || IsNumeric(cmdtext)) return SendClientMessage(playerid, 0xFF0000, "That's an invalid ID.");
    if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000, "That player isn't in your car.");
    if(random(10) == 1)
    new PName[MAX_PLAYER_NAME];
    new KidnapString[40];
    {
        SendClientMessage(playerid, 0xFFFF00, "The kidnap was successful.");
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "%s has kidnapped you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
    }
    else
    {
        GetPlayerName(KidnapID, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), The kidnap failed and %s noticed you tried to kidnap him!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);
        GetPlayerName(playerid, PName, sizeof(PName));
        format(KidnapString, sizeof(KidnapString), "
%s has attempted to kidnap you!", PName);
        SendClientMessage(KidnapID, 0xFF0000, KidnapString);   
    }
    return 1;
}
There's a 1/10 chance you'll successfully kidnap.
Hey man,
I take part of your code and put in my own way.
There's a little warning, check this out:

Код:
warning 202: number of arguments does not match definition
Follow the line, where is getting warning:

Код:
				if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid))){
				  SendClientMessage(playerid, COLOR_YELLOW, "Message here");
				  return 1;
				}
You know what is?
Reply
#8

pawn Код:
if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid)))//Seems wrong.

if(IsPlayerInVehicle(playerid, VehicleID))//This is how I have seen it. Two parts playerid, vehicleid.

if(!IsPlayerInVehicle(KidnapID, GetPlayerVehicleID(playerid)))//So try this. Not tested.
pawn Код:
if(GetPlayerVehicleID(KidnapID) != GetPlayerVehicleID(playerid))//Not tested.
I would test for you but got work. Sorry.
Reply
#9

Quote:
Originally Posted by ♦۞pкћп§-шŧųĄ۞♦
pawn Код:
if(!IsPlayerInVehicle(GetPlayerVehicleID(playerid)))//Seems wrong.

if(IsPlayerInVehicle(playerid, VehicleID))//This is how I have seen it. Two parts playerid, vehicleid.

if(!IsPlayerInVehicle(KidnapID, GetPlayerVehicleID(playerid)))//So try this. Not tested.
pawn Код:
if(GetPlayerVehicleID(KidnapID) != GetPlayerVehicleID(playerid))//Not tested.
I would test for you but got work. Sorry.
I get your ideia.
But 'VehicleID' isn't exist :P
Should I define first of all?
Reply
#10

pawn Код:
if(GetPlayerVehicleID(KidnapID) != GetPlayerVehicleID(playerid))//Not tested.
Use that :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)