-
Posts
2,947 -
Joined
-
Last visited
Everything posted by JR10
-
Something like: Just an example to show you how. --client side addEventHandler("onClientPreRender", root, function() local x, y, z = getElementPosition(obj) setCameraMatrix(0, 0, 0, x, y, z) end) Here, 0,0,0 are where the camera will stay. x,y,z are the coords of the object and the camera will keep rotation with the obj, something like exactly what you want. However, you need to trigger a client event that will add that handler, maybe pass the object somehow. And then later when the intro is done trigger a client event that will remove the event handler, or just make a timer.
-
Try: local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution function createText ( ) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) -- Get player's coordinates. local playerZoneName = getZoneName( playerX, playerY, playerZ ) -- Get name of the player's zone. dxDrawText( playerZoneName, 0.95, screenHeight-37, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) -- Draw Zone Name text shadow. dxDrawText( playerZoneName, 0.95, screenHeight-40, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Draw Zone Name text. end function HandleTheRendering() showPlayerHudComponent("area_name", false) addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. setTimer(function() removeEventHandler("onClientRender",rootElement,createText) end,1500,0) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering)
-
It should work. addEventHandler("onClientResourceStart", resourceRoot, function() showPlayerHudComponent("area_name", false) end) Post errors/warnings.
-
addEventHandler("onClientResourceStart", root, function() showPlayerHudComponent("area_name", false) end)
-
addEventHandler("onPlayerJoin", root, function() showPlayerHudComponent(source, "area_name", false) end) offtopic: there is a member with the same signature, so i think you should change it.
-
That's because you are using a timer to call "spawn" which will spawn the player back at the default position. here: addEventHandler("onPlayerWasted", root, function() local x = -1942 local y = 537 local z = 277 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) end )
-
Post the updated code, and point out the warning/error line.
-
Respawns you, how? It shouldn't respawn you at all, unless you made a script for it, with "onPlayerWasted".
-
Not sure, but you can do something like: addEventHandler("onClientPreRender", root, function() local x, y, z = getElementPosition(plane) setCameraMatrix(px, py, pz, x, y, z) end) Plane here must be the plane's variable you may set it's id server side to use it client side by "getElementByID". px, py, pz is the position where the camera will be. x, y, z is the look at, we get the planes position and set's the camera matrix to look at it.
-
Well, with bandi's code the player will spawn, but you will still see a black screen. And next time, use the wiki and the search in it. For spawning a player you must use 3 functions: fadeCamera -- fades the player's camera to a color or back to normal setCameraTarget -- used to make the camera follows the player (or follows another player 'spectate') spawnPlayer -- spawns the player Example: addEventHandler("onPlayerJoin", root, function() local x = -1942 local y = 537 local z = 277 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) end) You can change the x, y, z. Good luck.
-
for i,k in ipairs (getElementsByType("vehicle")) do if i == 5 then break end end
-
addCommandHandler ( "save", function(player) -- if hasObjectPermissionTo ( player, "resource.save", false ) then if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) local x, y, z = getElementPosition(vehicle) local model = getElementModel(vehicle) local rx, ry, rz = getElementRotation(player) local vehcode = {model, x, y, z, rx, ry, rz} outputChatBox ("Saved ",source) triggerEvent("vehicleSave",getRootElement(), vehcode) elseif (player) then local x, y, z = getElementPosition(player) local r = getPedRotation(player) local skin = getPedSkin(player) local int = getElementInerior(player) local dim = getElementDimension(player) local ped = {x, y, z, r, skin, int, dim} triggerEvent("savePlayer",getRootElement(), ped) end --[[ else outputChatBox("you aren'pt allowed to use this",source, end]] end) addCommandHandler("saveAV", -- save All Vehicles function(player) -- if hasObjectPermissionTo ( player, "resource.save", false ) then local vehicles = getElementsByType("vehicle") triggerEvent("AV",getRootElement(), vehicles) -- end end) addEvent("savePlayer",true) addEventHandler("savePlayer",getRootElement(), function(ped) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then local time = getRealTime() ped = table.concat(ped, " ") fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,ped) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end) addEvent("vehicleSave",true) addEventHandler("vehicleSave",getRootElement(), function(vehcode) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then vehcode = table.concat(vehcode, " ") local time = getRealTime() fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,vehcode) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end) addEvent("AV",true) addEventHandler("AV",getRootElement(), function(vehicles) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then local time = getRealTime() fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,vehicles) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end) With a space.
-
addCommandHandler ( "save", function(player) -- if hasObjectPermissionTo ( player, "resource.save", false ) then if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) local x, y, z = getElementPosition(vehicle) local model = getElementModel(vehicle) local rx, ry, rz = getElementRotation(player) local vehcode = {model, x, y, z, rx, ry, rz} outputChatBox ("Saved ",source) triggerEvent("vehicleSave",getRootElement(), vehcode) elseif (player) then local x, y, z = getElementPosition(player) local r = getPedRotation(player) local skin = getPedSkin(player) local int = getElementInerior(player) local dim = getElementDimension(player) local ped = {x, y, z, r, skin, int, dim} triggerEvent("savePlayer",getRootElement(), ped) end --[[ else outputChatBox("you aren'pt allowed to use this",source, end]] end) addCommandHandler("saveAV", -- save All Vehicles function(player) -- if hasObjectPermissionTo ( player, "resource.save", false ) then local vehicles = getElementsByType("vehicle") triggerEvent("AV",getRootElement(), vehicles) -- end end) addEvent("savePlayer",true) addEventHandler("savePlayer",getRootElement(), function(ped) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then local time = getRealTime() ped = table.concat(ped, ",") fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,ped) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end) addEvent("vehicleSave",true) addEventHandler("vehicleSave",getRootElement(), function(vehcode) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then vehcode = table.concat(vehcode, ",") local time = getRealTime() fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,vehcode) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end) addEvent("AV",true) addEventHandler("AV",getRootElement(), function(vehicles) local file = fileOpen("positions.txt") if not file then file = fileCreate("positions.txt") outputDebugString("Creating positions.txt") end if file then local time = getRealTime() fileSetPos(file,fileGetSize(file)) local written = fileWrite(file,vehicles) fileFlush(file) fileClose(file) if written then outputChatBox("Succesfully saved to positions.txt",source) end else outputDebugString("Save: Cannot find or create positions.txt") end end)
-
That's an example, just like she did in the first post.
-
How do you remove a blip created with createBlipAttachedTo?
JR10 replied to falseprophet's topic in Scripting
Store it in a variable and use: destroyElement Something like: local Blips = {} addEventHandler("onPlayerJoin", root, function() Blips[source] = createBlipAttachedTo() end) --destroy it later destroyElement(Blips[source]) Blips[source] = nil -
--Client side function test () ped = createPed ( 111, 0, 0, 4 ) car = createVehicle ( 411, 0, 0, 4 ) setPedControlState ( ped, "accelerate", true ) triggerClientEvent("onTestFunction", getLocalPlayer(), ped, car) end addCommandHandler ( "setup", test ) --server side addEvent("onTestFunction", true) addEventHandler("onTestFunction", root, function(ped, car) warpPedIntoVehicle ( ped, car ) end)
-
That's because it's a server side only function.
-
Can you post what you did, so that if someone searches for such topic he finds the answer.
-
local myColShape = createColSphere ( 1651.1312255859,-2543.0141601563,17.234375 ) local random_spawns = { [1]={1651.1312255859,-2543.0141601563,17.234375}, [2]={1651.1312255859,-2543.0141601563,13.546875}, [3]={1651.1312255859,-2543.0141601563,17.234375}, [4]={1651.1312255859,-2543.0141601563,13.546875}, [5]={1651.1312255859,-2543.0141601563,17.234375}, [6]={1651.1312255859,-2543.0141601563,15.602038383484}, [7]={1651.1312255859,-2543.0141601563,13.546875}, [8]={1651.1312255859,-2543.0141601563,13.546875}, [9]={1651.1312255859,-2543.0141601563,13.546875}, [10]={1651.1312255859,-2543.0141601563,15.602038383484} } function onClientColShapeHit3( theElement, matchingDimension ) if theElement == getLocalPlayer() then if source == myColShape then local rand_int = math.random(1,table.getn(random_spawns)) triggerServerEvent ( "super", getLocalPlayer()) setElementPosition(getLocalPlayer(),random_spawns[rand_int][1],random_spawns[rand_int][2],random_spawns[rand_int][3]) -- setElementInterior(getLocalPlayer(),15, random_spawns[rand_int][1],random_spawns[rand_int][2],random_spawns[rand_int][3]+5) end end end addEventHandler("onClientColShapeHit",root,onClientColShapeHit3) function aha2( ) setElementInterior(source,0) end addEvent ( "super", true ) addEventHandler ( "super", getRootElement(),aha2 )
-
I still don't get why there are humans learning or scripting in Pawn. Anyway, I will try to help you, if i understood you correctly. Library in Lua: Well, a library as you said is something like a resource, that provides functions. Well, here it's a resource that provides exported functions which can be used by another resources. A script file in the resource (library): function setPlayerMoney(player, money) --code end function sayHi(player) outputChatBox("Hi.", player) end Those the functions we want to use in another resources. In order to do so, you have to export the functions: meta.xml: <export function="setPlayerMoney" type="server" /> <export function="sayHi" type="server" /> And you are done, now both functions can be used in any script file, but it must be server side, because we specified the type "server". Way of using the exported functions. exports.resourceName.functionName(arguments) That's it, resourceName is the name of the resource which have the exported functions, functionName is the function name we want to use, so it will be something like: i will call the resource exportedFunctions. addEventHandler("onPlayerJoin", root, function() exports.exportedFunctions.sayHi(source) end) Events: Example of making a new event, using it in another resource. addEvent("onPlayerJoinEx") addEventHandler("onPlayerJoin", root, function() triggerEvent("onPlayerJoinEx", source) end) In another resource addEvent("onPlayerJoinEx") addEventHandler("onPlayerJoinEx", root, function() outputChatBox("Hi.", source) end) Source here will be the player who joined, why?, because we specified the second argument @ triggerEvent "source". Which is the player who joined in onPlayerJoin, so now onPlayerJoinEx 's source is the player who joined.
-
try this: <team name="Team Name" color="#00FF00" tag="[TM]" />
-
setPedFrozen setTimer ???? like: --on Player enter the interior setPedFrozen(player, true) setTimer(setPedFrozen, 1000, 1, player, false) And next time try something yourself first.