NEW QUESTION, FORGET THE CAMOFLAUGE i wanna spawn a vehicle in a command.
#7

seriously, buy a book on any scripting language, and learn it from the bottom up... let's go through what you want..

Код:
command: /nrg
 - check if the player has enough money
  > no? close command
  > yes? continue command

 - creates a vehicle at playerids location
 - put playerid on the vehicle
 - charge money
 - make a nice message
this is the mental bit about creating this command.. so next is: how do you transfer your idea to code? Well, we need several things: a check if the command is /nrg, a check if the player has enough money, we need the players location and a few commands to make a vehicle and charge money.

pawn Код:
if (strcmp("/nrg", cmdtext, true) == 0) // check command
{
  if(GetPlayerMoney(playerid) <= 17750) // check money
    return SendClientMessage(playerid,red, "You need $17,750"); // if not enough money, stop the command, else continue

  // now we need the player position
  new Float:x, Float:y, Float:z, Float:a;
  GetPlayerPos(playerid,x,y,z);
  a = GetPlayerFacingAngle(playerid);

  // now create the vehicle and put the player on it
  new vehid = CreateVehicle(model, x, y, z, a, color1, color2, respawn_delay);
  PutPlayerOnVehicle(playerid, vehid, 0);

  // charge money
  GivePlayerMoney(playerid, -17750);

  // message
  SendClientMessage(playerid, COLOR_SOMETHING, "Here's your NRG-500!");

  // end command
  return 1;
}
that's all there is to it.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)