Advertisement
Anik1204

NPC - AddCar

May 19th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. local model = GetTok(text, " ", 1);
  2. if (!model) MessagePlayer("/" + cmd + " [model] [colour1] [colour2]", player);
  3. else if (!IsNum(model)) MessagePlayer("[#FF0000][ ERROR ] Car model must be a number.", player);
  4. else
  5. {
  6. local cor1 = GetTok(text, " ", 2);
  7. if (!cor1) MessagePlayer("/" + cmd + " [model] [colour1] [colour2]", player);
  8. else if (!IsNum(cor1)) MessagePlayer("[ ERROR ] Car colour1 must be a number.", player);
  9. else
  10. {
  11. local cor2 = GetTok(text, " ", 3);
  12. if (!cor2) MessagePlayer("/" + cmd + " [model] [colour1] [colour2]", player);
  13. else if (!IsNum(cor2)) MessagePlayer("[ ERROR ] Car colour2 must be a number.", player);
  14. else
  15. {
  16. local x = player.Pos.x, y = player.Pos.y, z = player.Pos.z, angle = player.Angle;
  17. player.Pos.z += 2;
  18. CreateVehicle(model.tointeger(), 0, Vector(x.tofloat(), y.tofloat(), z.tofloat()), angle.tofloat(), cor1.tointeger(), cor2.tointeger());
  19. QuerySQL(db, "INSERT INTO `Cars` VALUES ( '" + GetVehicleCount() + "', '" + FindVehicle(GetVehicleCount()).Model + "', '1', 'None', 'None', '', '', '0', '0', '0', '0', '" + cor1 + "', '" + cor2 + "', '" + x.tofloat() + "', '" + y.tofloat() + "', '" + z.tofloat() + "', '" + angle.tofloat() + "' )");
  20. ClientMessageToAll("* Admin [" + rgbtohex(player.Colour.r, player.Colour.g, player.Colour.b) + "]" + player.Name + "[$FF] has added a [#FFFFFF]" + GetVehicleNameFromCustomModel(model.tointeger()) + "[$FF] in " + GetDistrictName(player.Pos.x, player.Pos.y) + ". *", 190, 190, 190);
  21. CarStats.append( GetVehicleCount() );
  22. CarStats[GetVehicleCount()] = CarClass();
  23. CarStats[GetVehicleCount()].ID = GetVehicleCount();
  24. CarStats[GetVehicleCount()].Model = FindVehicle(GetVehicleCount()).Model;
  25. CarStats[GetVehicleCount()].Price = 0;
  26. CarStats[GetVehicleCount()].Owner = "None";
  27. CarStats[GetVehicleCount()].Shared = "None";
  28. CarStats[GetVehicleCount()].XP = 0;
  29. CarStats[GetVehicleCount()].YP = 0;
  30. CarStats[GetVehicleCount()].ZP = 0;
  31. CarStats[GetVehicleCount()].Angle = 0;
  32. CarStats[GetVehicleCount()].Col1 = cor1.tointeger();
  33. CarStats[GetVehicleCount()].Col2 = cor2.tointeger();
  34. CarStats[GetVehicleCount()].XO = x.tofloat();
  35. CarStats[GetVehicleCount()].YO = y.tofloat();
  36. CarStats[GetVehicleCount()].ZO = z.tofloat();
  37. CarStats[GetVehicleCount()].OAngle = angle.tofloat();
  38. MessagePlayer("[#01DFA5]Vehicle successfully added to Database.", player);
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement