Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Everything posted by SDK

  1. Did you try setPedRotation?
  2. That only works with lua commandhandlers, not hardcoded commands like /debugscript /say /quit I believe.
  3. Not tested (use [lua] for colored code) local firetime = 1000 local canfire = true local myTimer function reloadVehicleGuns() if (canfire == false) then outputChatBox ( "Primary gun reloaded!") end canfire = true toggleControl ( "vehicle_fire", true ) end function vehicleWeaponFire(key, keyState) local vehModel = getElementModel(getPedOccupiedVehicle(getLocalPlayer())) if (vehModel == 425) then if (canfire == true) then canfire = false outputChatBox ( "Primary weapon released!") myTimer = setTimer (reloadVehicleGuns, firetime, 1 ) toggleControl ( "vehicle_fire", false ) end end end bindKey("vehicle_fire", "down", vehicleWeaponFire)
  4. How about this: local myMarkers = { createMarker( 0, 0, 4, 'cylinder', 1, 255, 0, 0, 150 ), createMarker( 0, 2, 4, 'cylinder', 1, 255, 0, 0, 150 ), createMarker( 0, 4, 4, 'cylinder', 1, 255, 0, 0, 150 ), createMarker( 0, 6, 4, 'cylinder', 1, 255, 0, 0, 150 ), createMarker( 0, 8, 4, 'cylinder', 1, 255, 0, 0, 150 ) } function PlayerMarkerHit( markerHit, matchingDimension ) local player = source for k, marker in ipairs(myMarkers) do if marker == markerHit then destroyElement ( markerHit ) return end end giveWeapon ( player, 31 ) end addEventHandler( "onPlayerMarkerHit", root, PlayerMarkerHit ) 2) Search for "bone" in community or this one https://community.multitheftauto.com/index.php?p= ... ls&id=1823
  5. Well, check if the player has a vehicle. If yes, use the vehicle element, else use the player element. Or doesn't it suit what you need?
  6. I'll still add this: https://wiki.multitheftauto.com/wiki/SaveMapData
  7. You don't need to, global variables can be shared between script files in the same resource(but only on the same side: server-server and client-client)
  8. Hm, I don't see an error on first sight, which line is line 19? Maybe the drawing coordinates are off-screen. Also, try reducing your code. Instead of putting an dxDrawText every elseif, make a variable for the color and change it (or store the colors in some table or even better: make some formula for it). That should make you able to spot the error easier.
  9. SDK

    car under water

    I believe you just put the spawns underwater. If you want them to get out of the water, you can use a boat/seasparrow or even with a car which has enough speed maybe.
  10. SDK

    Texturizer info

    Well, here's the authors topic from the module: viewtopic.php?p=332579 It has some info about the function syntax. The author hasn't been active since 15 feb tho ...
  11. No, the handlerfunction has a different syntax between server- an clientside. Serverside, the first argument is the player who entered the command. Clientside commands only work for the local player (you don't know if another player has entered a clientside command), so the player element you will use is getLocalPlayer(). https://wiki.multitheftauto.com/wiki/AddCommandHandler The only time hidden variables are used is when using events iirc. They are globale and exist only during the function call, and get deleted after all the code is executed. "source" is the most used and important one, you also have some others listed here, but the only one that is important from those is the "client" variable (only when you use triggerServerEvent). The reason is because you used a timer after dieing. Like I said above, source only exists during the event handler function call and gets removed afterwards. So if you die and playerSpawnAt is executed after 2 seconds, source is lost already. The playerSpawnAt function works with onPlayerJoin since it's executed immediately, so source still exists. But I modified the doJoin part too, since I already had changed the playerSpawnAt function due to the timer. Well, I hope I explained everything correctly ^^
  12. You need to pass the player element to the playerSpawnAt function, the 'source' variable doesn't exist there anymore. -- Learning MTA's script system function playerSpawnAt(player, x, y, z) outputChatBox("Calling: playerSpawnAt("..x..", "..y..", "..z..")", player) spawnPlayer(player, x, y, z) setCameraTarget(player, player) fadeCamera(player, true) end function doOnJoin() outputChatBox("Calling: doOnJoin()", source) playerSpawnAt(source, 2031, -1405, 17.4) end function doOnDeath() outputChatBox("Calling: doOnDeath()", source) setTimer(playerSpawnAt, 2000, 1, source, 2031, -1405, 17.4) end addEventHandler("onPlayerJoin", getRootElement(), doOnJoin) addEventHandler("onPlayerWasted", getRootElement(), doOnDeath)
  13. I heard you first need to play a few hours/days on some popular mta servers.
  14. That's wrong actually, it wouldn't output anything. ipairs() starts from index [1] and stops when the next value is 'nil'. http://codepad.org/qDdrWXgi
  15. You can use the mapcycler to deal with it, put it in vote mode and you can trigger it when everyone died using triggerEvent("onRoundFinished", getResourceRootElement(getThisResource())) https://wiki.multitheftauto.com/wiki/Resource:Mapcycler Another way is to make a custom poll with your own (randomly) chosen maps. You create a table with all the options you want, and start it using exports.votemanager:startPoll ( polltable ). https://wiki.multitheftauto.com/wiki/Res ... otemanager
  16. This should be moved to the Scripting section Anyway, you should use the source of the event to pass on the player element, and then you can use it to spawn him. --gui button leads to triggerServerEvent ( "onChooseSpawn", getLocalPlayer(), 105 ) --set "source" to local player element addEvent( "onChooseSpawn", true ) function spawnHandler ( skinID ) local player = source setCameraTarget ( player ) fadeCamera ( player, true ) spawnPlayer ( player, 2495, -1685, 14, 0, skinID) end addEventHandler( "onChooseSpawn", getRootElement(), spawnHandler )
  17. Ah, I thought you linked to the wrong one since there id's are almost the same
  18. I want cake DemoN linked to the wrong resource: https://community.multitheftauto.com/index.php?p= ... ils&id=960
  19. Stop pming people (me) if you need help. First thing I noticed is that you didn't add the even serverside with addEvent("buttonClicked", true), this should've given an error in /debugscript 3. But since there are no errors (atleast you say so), there are likely other problems.
  20. if ( getPlayerPing( ThePlayer ) < 90 ) then shouldn't that be: if ( getPlayerPing( ThePlayer ) > 90 ) then
  21. Yeah, it's hidden in the resource catalogue https://wiki.multitheftauto.com/wiki/Resource:Race Yup, and math.random(1,#carids) is the same as math.random(#carids). If you give one parameter for math.random, it returns a number between 1 and the parameter. time = time since the race started, in milliseconds. And yeah, it's kinda a placeholder, but you can remove it if you want. Lua will not complain if you don't define all the variables that are passed through a function.
  22. hai thar local carids = {429, 541, 415, 480, 562, 565, 434, 494, 502, 503, 411, 559, 561, 560, 506, 451, 558, 555, 477, 602, 496, 401, 518, 527, 589, 419, 533, 526, 474, 545, 517, 410, 600, 436, 580, 439, 549, 491, 445, 604, 507, 585, 587, 466, 492, 546, 551, 516, 467, 426, 547, 405, 409, 550, 566, 540, 421, 529, 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 468, 586, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 433, 427, 490, 528, 407, 544, 523, 470, 598, 596, 597, 599, 432, 601, 428, 499, 609, 498, 524, 532, 578, 486, 406, 573, 455, 588, 403, 514, 423, 414, 443, 515, 531, 456, 459, 422, 482, 605, 530, 418, 572, 582, 413, 440, 543, 583, 478, 554, 536, 575, 534, 567, 535, 576, 412, 402, 542, 603, 475, 568, 424, 504, 457, 483, 508, 571, 500, 444, 556, 557, 471, 495, 539, 579, 400, 404, 489, 505, 479, 442, 458} local boatids = {472, 473, 493, 595, 484, 430, 453, 452, 446, 454} local planeids = {592, 577, 511, 548, 512, 593, 425, 520, 417, 487, 553, 488, 497, 563, 476, 447, 519, 460, 469, 513} function randomCar(checkpoint, time) local veh = getPedOccupiedVehicle(source) if 1 <= checkpoint and checkpoint <= 8 then setElementModel (veh, carids[math.random(#carids)]) elseif checkpoint <= 11 then setElementModel (veh, boatids[math.random(#boatids)]) elseif checkpoint <= 15 then setElementModel (veh, carids[math.random(#carids)]) elseif checkpoint <= 17 then setElementModel (veh, planeids[math.random(#planeids)]) end end addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', getRootElement(), randomCar) No need for all the markers, race has a checkpoint event (and you won't need to check if the player exists and has a vehicle) No need for so many if's, you can say "between those checkpoints"
  23. This can be done with https://wiki.multitheftauto.com/wiki/CallRemote, look at example #2. It's for chatting between servers, but you can modify it to what you want. You still need to make proper acl rights and groups, that's the hard part.
  24. You can go to the web page of your server while it's running: http://127.0.0.1:22005/resourcebrowser/ It will display all resources, the ones that failed to load will be red.
  25. This used to be possible, but servers can abuse it, so it got disabled. http://bugs.mtasa.com/view.php?id=5123 You can store the nick local in a file, when the player joins read the file and set his nick.
×
×
  • Create New...