PutPlayerInVehicle
#1

Hey, i've set out 8 vehicle spawns for a minigame...

the player types in a command, the minigame signup timer is activated.

Then the vehicles are spawned in world 200. If nobody else joins the minigame, then the player gets a message saying it was cancelled, gets a refund of the money, and the vehicles are destroyed.

If somone else does join the minigame, im wanting it to put each of the players who joined, into one of the vehicles.

So if theres three players in the minigame, each of the players will be put in one of the vehicles, then the 3 taken vehicles will be put into virtualworld 111

I've had it working as far as, spawning the vehicles, the vehicles destroying if there aren't enough players joined. The part im having trouble with is the players being put into a sepperate vehicle, then those vehicles being set into world 111. i can set the vehicles and the players into world 111, but when PutPlayerInVehicle is used, the first player is put into the vehicle, then is carjecked by the next player..

So how can i put each player into 1 of 8 vehicles?
Reply
#2

Anybody wanna help me with this one please?
Reply
#3

Reply
#4

nobody know the answer to this?
Reply
#5

Reply
#6

Should allready be a post like this somewhere with an answear, Search it
Reply
#7

try doing this for each player.

PutPlayerInVehicle(playerid,playerid,0);
This means their playerid, is put in the vehicle with the same ID as them. This means unless you have two players with the same ID (not possible) they'll all get seperate vehicles.

Note; if vehicleids start at 1, not 0, use PutPlayerInVehicle(playerid,playerid+1,0);
Reply
#8

but that would mean if theres 8 vehicles and id9 needs to be put in a vehicle, nothing will happen
Reply
#9

It works fine. I've used this method before.
Reply
#10

above on gamemode init:


new v1;
new v2;
new v3;
new v4;
new v5;
new v6;
new v7;
new v8;

new score[1]; // we will use this to see how many people are in the dm

(if you want more people joining your dm add more of these)
Код:
if(strcmp(cmdtext, "/minigame", true == 0)
{ 
   if(score[0] == 0)
   {
     v1 = CreateVehicle(model, float:x, float:y, float:z, x, y, z); // note that the last three are the vehicles Z AXIS
     PutPlayerInVehicle(playerid, v1, 0);
     SendClientMessage(playerid,COLOR_RED,"Welcome to the minigame. You Have Spawned in a vehicle");
     SetPlayerWorld(playerid, 200);
     Score[1] += 1;
   }
   (do this right up to score == the number of players you want in your dm)
   else
   {
     SendClientMessage(playerid,COLOR_RED,"We're Sorry, That DeathMatch Zone Is Full At The Moment");
   }
Dont Forget, we need to lower the DM count of players upon leaving the deathmatch, this can be done using playerinfo, read about some of the other topics ive posted in for more on this.


Reply
#11

thats the most useless code ever. My one line method works perfectly fine.
Reply
#12

point taken; most of my coding is useless!



ah, and yes, your one line coding does work fine
Reply
#13

jolteon, your code would only work for the first 8plsyers.

If id 8,9,10+ were needing to be put into one of the 8 vehicles, it would be impossible because there is only 8 vehicles, so there wouldn't be a vehicle that would match their playerid.

Does anyone have a solution to this?

I've already searched, so don't waste my time and yours by saying search, or posting a link to search.
Reply
#14

Try creating a vehicle when they enter the command to enter a minigame, a bit like this

pawn Код:
OnPlayerCommandText(playerid,cmdtext[])
{

  [....]

  if (strcmp(command, "/blahblah") == 0)
  {
    new vehid = CreateVehicle(...................);
    PutPlayerInVehicle(playerid, vehid, 0);

    [....]
    return 1;
  }

  [....]
  return 1;
}
Reply
#15

already tried something similar, it didnt work very well.

Is there a way to check if a player is near a vehicle? Like there is to check for the nearest player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)