Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Everything posted by SDK

  1. You could use colshapes for that: colShape = createColCircle(0,0,10) --radius=10 addEventHandler('onColShapeHit',colShape, function(element) if getElementType(element) == 'player' then outputChatBox('You are near the 0,0 point!', element) end end )
  2. Yes, but now you changed your index name, that's some basic Lua table stuff. VehicleInfo[idx].VehID = row[1] -- this is the same as : VehicleInfo[idx]["VehID"] = row[1] -- but NOT the same as: VehicleInfo[idx][VehID] = row[1]
  3. Yes, VehicleInfo[idx] is nil, so you're trying to get nil["VehID"] which is impossible. You need to define a table inside the first table: VehicleInfo = {} .... VehicleInfo[idx] = {} VehicleInfo[idx].VehID = row[1] ...
  4. SDK

    Falling

    According to the Killmessages resource, falling dead is weapon ID 54: Clientside: function stopFallingDamage ( attacker, weapon, bodypart ) if ( weapon == 54 ) then cancelEvent() end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopFallingDamage )
  5. Using files in directory's can be quite tricky sometimes, try this (notice the backslashes): meta.xml <file src="textures\billbrd01_lan.txd" /> <file src="textures\billbrd01_lan2.txd" /> <script src="textures.lua" type="client" /> textures.lua function replaceTXD() txd = engineLoadTXD("textures\\billbrd01_lan.txd") engineImportTXD(txd, 4238) txd = engineLoadTXD("textures\\billbrd01_lan2.txd") engineImportTXD(txd, 4729) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceTXD)
  6. But where is skinID? And where is source? They dont exist here
  7. What Solidsnake14 wrote works fine, you probably copied it wrong, show us your code
  8. Nice job, looking forward to 1.1 and your editor.
  9. Don't use element data: local CharacterSkin = 26 local CharacterName = "John" triggerServerEvent("charSelected", getLocalPlayer(), CharacterSkin, CharacterName) function charaSelected(CharacterSkin, CharacterName ) spawnPlayer(source, 1910.55, -1714.46, 10, 0, CharacterSkin) setPlayerName(source, CharacterName ) fadeCamera(source, true) setCameraTarget(source) end addEvent("charSelected",true) addEventHandler("charSelected",getRootElement(),charaSelected)
  10. Yeah cause my table name was wrong, "locations" and "location", they should be the same And about the blips, this code is meant as an example, you'll have to rewrite it into a server and client file, using events to trigger stuff
  11. One simple search on the wiki https://wiki.multitheftauto.com/wiki/Interior
  12. You could try this way, using one table with all locations, and randomly selecting one location from it. local pizzablip, pizzamarker, house local locations = {} location[1] = { x = 2363.1, y = -1672, z = 13.5, blipicon = 32, reward = 100 } location[2] = { x = 2157.4, y = -1792, z = 13.3, blipicon = 32, reward = 250 } -- add other locations ... function enteredMissionvehicle (theVehicle,seat,jacked) if ( getElementModel ( theVehicle ) == 448 ) then -- if its a pizzaboy outputChatBox("You have entered a Pizza Delivery Vehicle, Deliver the Pizza to the Red House Blip on your MiniMap and type /deliver!", source,255,0,0) startRandomMission() end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enteredMissionvehicle ) function startRandomMission() house = locations[math.random(1,#locations)] pizzablip = createBlip ( house.x, house.y, house.z, house.blipicon, 2, 255, 0, 0 ) pizzamarker = createMarker ( house.x, house.y, house.z, "cylinder", 2, 255, 0, 0 ) end -- .... You'll still need to split things up in server and client side tho, else everyone will start seeing random blips.
  13. Yeah, found the problem. You should really start debugging btw, I didn't test the code but you did, and it would certainly throw an error. Use "/debugscript 3" in your testing server. addEventHandler("onCharSelect",getRootElement(),charSelect)
  14. When the lua file get's loaded, all code that's not in function() ... end stuff gets executed immediately, and I guess that line is the only one you added in the server file. For your window, you can't use local in createCharWindow, else it will not exist outside that function scope. Client: local charWindow = nil function charSelect() createCharWindow() guiSetVisible(windowLogin, false) if (not charWindow) then -- don't use "~= nil", it can be false and "false ~= nil" => true guiSetVisible(charWindow,true) else outputChatBox("Problem! (For scripting testing purposes)",getLocalPlayer()) end end addEvent("onCharSelect",true) addEventHandler("onCharSelect",getRootElement(),charSelect()) function createCharWindow() charWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, charWindow ) local inf1 = guiCreateTab(getElementData(getLocalPlayer(),"tabinf1"), tabPanel ) local inf2 = guiCreateTab(getElementData(getLocalPlayer(),"tabinf2"), tabPanel ) guiSetVisible(charWindow,false) end Server: function testclientwindow (player, command) triggerClientEvent(player, "onCharSelect", getRootElement() ) end addCommandHandler("testgui", testclientwindow)
  15. Do you by any chance mean going from a string (theMission) to a function? If so, you could use _G
  16. Hai thar The updating is fine, it's cause spawning in race is a little bit different. onClientPlayerSpawn is when the player respawns, but race hasn't put him in his vehicle yet. I usually use on(Client)PlayerVehicleEnter when scripting for race (re)spawns. I still see another problem with your "backup" tho, what if the player keeps respawning untill he's past one or more previous colshapes? What you could do is create a table that links all checkpoints to a colshape, and restore the gravity that way.
  17. Table comparison? You can't use == for that, and you probably don't need it. Post the rest of the relevant code please, it's too incomplete to make sense.
  18. You need to finish the script yourself, me or other people can't help if you don't give more info about what you did
  19. SDK

    Take player money

    Use [ lua][ /lua] I'm not sure what's wrong, what is the problem exactly? function take(thePlayer, command, who, amount) local taker = getPlayerName ( thePlayer ) local takeFrom = getPlayerFromName ( who ) if takeFrom and isObjectInACLGroup ( "user." .. taker, aclGetGroup ( "Admin" ) ) then takePlayerMoney (takeFrom, math.abs(tonumber(amount))) end end addCommandHandler ("take", take)
  20. + you should only send the event to one player, not all of them. triggerClientEvent ( player, "hideLoginWindow", getRootElement() ) triggerClientEvent ( player, "showSkinSelector", getRootElement() )
  21. Assuming skinID is a number and source is a ped server side bronezombies = { [167]=true, [277]=true, [264]=true } noheadzombies = { [70]=true, [108]=true, [128]=true, [188]=true, [259]=true } speedzombies = { [92]=true, [162]=true, [206]=true, [209]=true, [212]=true, [229]=true, [230]=true } firezombies = { [105]=true, [107]=true, [127]=true, [280]=true, [287]=true } function zombieclasses () if (bronezombies[skinID])then setPedStat (source, 24, 2000) setPedGravity (source, 0.009) elseif (noheadzombies[skinID] )then setPedHeadless(source, true) elseif (speedzombies[skinID] )then setPedStat (source, 24, 500) elseif (firezombies [skinID] )then setPedOnFire ( source, true ) end end To make them walk faster/slower, you can't use get/setGameSpeed. Maybe blendPedAnimation will help
  22. Or use dzek (varez)'s tools: http://mta.dzek.eu/
  23. createColCuboid So you fill in the southwest bottom corner as fx, fy and fz. And the width, depth and heigth would be fx1, fy1, fz1 = --southwest bottom corner coordinates fx2, fy2, fz2 = --north east upper corner coordinates width = fx2 - fx1 depth= fy2 - fy1 heigth = fz2 - fz1 I would use "createColRectangle" btw, no need for a z-coordinate
  24. 1. You can have one event attached to multiple functions if that's what you mean: addEvent("thePlayerSpawned", true) addEventHandler("thePlayerSpawned",getRootElement(), giveThePlayerSomeClothes) addEventHandler("thePlayerSpawned",getRootElement(), tellEveryoneThePlayerSpawned) addEventHandler("thePlayerSpawned",getRootElement(), giveHimSomeCashToStart) Now this would trigger all functions attached to it: triggerServerEvent("thePlayerSpawned", getLocalPlayer()) 2. Events can be called from the client to the server, but also from the server to the client
  25. It's not only an other file, the event will be called from the client to the server. Maybe you should try rereading this tutorial as well: https://wiki.multitheftauto.com/wiki/Scripting_Introduction#What_you_need_to_know You can download some simple login resource from the community to get some examples if you're still confused.
×
×
  • Create New...