Jump to content

Maurize

Members
  • Posts

    226
  • Joined

  • Last visited

Everything posted by Maurize

  1. i want to retrieve the number of specific players... for example: local players = getElementsByType( "player" ) for i, v in ipairs( players ) do if ( getDatabase( v, "Admin" ) > 0 ) then -- And now? I have to get all players which have this data "true" to a number and trigger it to client to fill the playerlist with this data... thanks,
  2. wow thanks alot, mates!! You are the best! And Jay, thanks for showing me a smarter and better way to work with tables:)
  3. hm okay, but i heared in ipairs i need a specified number to get the lines which are selected..
  4. u mean "while" or " for i, v in pairs" ?? example please..
  5. "Database query failed: Database is locked" - what does this mean? Before I've created another table, my sql database worked perfectly. addCommandHandler( "house", function( thePlayer, cmd, Int, Preis ) if ( getDatabase( thePlayer, "Admin" ) == 1 ) then local X1, Y1, Z1 = getElementPosition( thePlayer ) if ( Int == "1" ) then In = 5 X2 = 1298.9 Y2 = -796.4 Z2 = 1084.0 elseif ( Int == "2" ) then In = 1 X2 = 223.2 Y2 = 1287.5 Z2 = 1082.1 elseif ( Int == "3" ) then In = 5 X2 = 2233.7 Y2 = -1115.1 Z2 = 1050.9 elseif ( Int == "4" ) then In = 8 X2 = 2365.3 Y2 = -1135.6 Z2 = 1050.9 elseif ( Int == "5" ) then In = 11 X2 = 2283.0 Y2 = -1139.7 Z2 = 1050.9 elseif ( Int == "6" ) then In = 6 X2 = 2196.2 Y2 = -1204.4 Z2 = 1049.0 elseif ( Int == "7" ) then In = 10 X2 = 2269.8 Y2 = -1210.5 Z2 = 1047.6 elseif ( Int == "8" ) then In = 6 X2 = 2308.8 Y2 = -1212.8 Z2 = 1049.0 elseif ( Int == "9" ) then In = 2 X2 = 2237.5 Y2 = -1080.5 Z2 = 1049.0 elseif ( Int == "10" ) then In = 9 X2 = 2317.9 Y2 = -1026.2 Z2 = 1050.2 elseif ( Int == "11" ) then In = 5 X2 = 140.4 Y2 = 1366.6 Z2 = 1083.9 end executeSQLInsert( "HouseData", "'0', '"..Preis.."', '"..In.."', '"..X1.."', '"..Y1.."', '"..Z1.."', '"..X2.."', '"..Y2.."', '"..Z2.."'" ) createPickup( X1, Y1, Z1, 3, 1272, 2000 ) end end ) & is it possible to get all data which is in table? I'm working on housing system and need to create a pickup for every line ( 1 Line = 1 House ) addEventHandler( "onResourceStart", resourceRoot, function() executeSQLCreateTable( "HouseData", "Name STRING, Preis INT, Int INT, PosX FLOAT, PosY FLOAT, PosZ FLOAT, IntX, IntY, IntZ" ) local db = executeSQLSelect( "HouseData", "*" ) if ( db ) then createPickup( db[1]["PosX"], db[1]["PosY"], db[1]["PosZ"], 3, 1272, 2000 ) end end ) Thanks.
  6. excatly what I've searched for! Alpha you're the best!
  7. Simply create a ped with dead-animation on this place... it will sure work with client click and this stuff... try to find a way to work arround your problem(:
  8. Hey, I need your help one time again. Math is not my best so I hope someone of you can help me out. I want to create peds, which "live" / "life" with animations, actions and so on. First thing is, that I need to get them walking. So first steps are done... I need to retrieve the coordinate 5 feet in front of my ped to get if line of sight is clear. All i have is the x, y, z position and rotation from ped. Is there a math code to get the 3 position coordinates in front of the ped? Hoping for fast help. Thanks!(: setTimer( function() local targets = getElementsByType( "ped" ) for i, target in ipairs( targets ) do local px, py, pz = getElementPosition( target ) if ( isLineOfSightClear( px, py, pz, px + 1, py + 1, pz + 1 ) == true ) then setPedControlState( target, "forwards", true ) setPedControlState( target, "walk", true ) else setElementRotation( target, 0, 0, math.random( 0, 360 ) ) setPedControlState( target, "forwards", false ) setPedControlState( target, "walk", false ) end end end, 1000, 0 )
  9. wow nice.. & 1 other question: what is the default dimension? I mean i've setted the elements dimension to 100.. hows the default of each other?
  10. addEventHandler( "onMarkerHit", elementPlayer, function( hitPlayer ) if ( isPedInVehicle( hitPlayer ) == false ) then if ( source == clubMarker ) then setElementInterior( hitPlayer, 2, 1204.9, -10.5, 1000.9 ) triggerClientEvent( "onElementClub", hitPlayer ) toggleControl( hitPlayer, "fire", false ) elseif ( source == clubMarker2 ) then setElementInterior( hitPlayer, 0, 2421.5, -1223.9, 25.3 ) triggerClientEvent( "onElementClub", hitPlayer ) toggleControl( hitPlayer, "fire", true ) end end end ) bad pointer at isPedInVehicle.. any ideas?
  11. addEventHandler( "onClientRender", getRootElement(), function() if ( isCursorShowing() == true ) then local sx, sy, wx, wy, wz = getCursorPosition" class="kw4">getCursorPosition() dxDrawImage( sx, sy, 55, 75, "mainFiles/elementCursor.png" ) end end ) Doen't work. Image is in the top-left corner... Anything wrong?
  12. this means the system is unable to read resource / script. you have to convert it tu utf8 i think, then it should work. otherwise open the script and watch out for strange symbols;)
  13. setElementData( element, "data", value ) --[[for code use:]] tostring( value ) or tonumber( value )
  14. Al3GRAB Your's doensn't work ... // Okay found another way to get it to work ;D
  15. Is it possible to trigger a client ped to server, so i can give the clientside ped a weapon for example?
  16. So I've created a other camera script.. But i want the arrow move with player but in front of him... I am not that good in math but I hope someone can help me out. local elementPed = createPed( 34, 2504.8, -1669.4, 13.4 ) local elementAim = createObject( 1318, 2504.8, -1669.4, 13.4, 0, 90, 0 ) -- arrow should work with player.. continue reading.. addEventHandler("onClientResourceStart", resourceRoot, function() showCursor( true, true ) setCameraTarget( getLocalPlayer(), elementPed ) fadeCamera( true, 1.0 ) bindKey( "w", "both", function() if ( getPedControlState( elementPed, "forwards" ) == true ) then setPedControlState( elementPed, "forwards", false ) else setPedControlState( elementPed, "forwards", true ) end end ) end ) addEventHandler( "onClientRender", getRootElement(), function() local sx, sy, wx, wy, wz = getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition() local px, py, pz = getElementPosition( elementPed ) local rz = - math.deg( math.atan2( px - wx, py - wy ) ) - 180 setCameraMatrix( px, py, pz + 20, px, py, pz ) if ( elementPed ) and ( elementAim ) then setPedCameraRotation( elementPed, rz ) setPedRotation( elementPed, rz ) setElementPosition( elementAim, px * rz / 180, py * rz / 180, pz ) -- get Cursor in front of Player not working.. setElementRotation( elementAim, 0, 90, rz ) -- get Cursor in rotation working.. else outputDebugString( "Error!" ) end end )
  17. Okay, working but with bugs( ped starts running but in wrong direction and endless .. ) .. check yourself: multiData = getRootElement() singleData = getLocalPlayer() element = createPed( 0, 2504.8, -1669.4, 13.4 ) addEventHandler("onClientResourceStart", resourceRoot, function() showCursor( true, true ) setCameraTarget( singleData, element ) fadeCamera( true, 1.0 ) end ) addEventHandler( "onClientPreRender", multiData, function() local rot = getPedRotation( element ) if ( getKeyState( "a" ) ) then rot = rot + 3 end if ( getKeyState( "d" ) )then rot = rot - 3 end local px, py, pz = getElementPosition( element ) local dx, dy, dz = getTransformedPosition( element, 0, -10, 10 ) setCameraMatrix( dx, dy, dz, px, py, pz ) setPedRotation( element, rot ) setPedCameraRotation( element, rot ) end ) local destX, destY, destZ = 0, 0, 0 addEventHandler( "onClientClick", multiData, function( button, state, absX, absY, worldX, worldY, worldZ, element ) if ( button == "left" ) and ( state == "down" )then destX, destY, destZ = worldX, worldY, worldZ local px, py, pz = getElementPosition( element ) local rot = - math.deg( math.atan2( px - destX, py - destY ) ) - 180 setPedCameraRotation( element, rot ) setPedRotation( element, rot ) addEventHandler("onClientRender", multiData, setTransformedPosition ) end end ) function setTransformedPosition() setPedControlState( element, "forwards", true ) local x, y, z = getElementPosition( element ) local dist = getDistanceBetweenPoints2D( destX, destY, x, y ) if( dist <= 0.2 )then removeEventHandler( "onClientRender", multiData, setTransformedPosition ) setPedControlState( element, "forwards", false ) end end function getTransformedPosition( element, distX, distY, distZ ) local matrix = getElementMatrix( element ) local offX = distX * matrix[1][1] + distY * matrix[2][1] + distZ * matrix[3][1] + 1 * matrix[4][1] local offY = distX * matrix[1][2] + distY * matrix[2][2] + distZ * matrix[3][2] + 1 * matrix[4][2] local offZ = distX * matrix[1][3] + distY * matrix[2][3] + distZ * matrix[3][3] + 1 * matrix[4][3] return offX, offY, offZ end
  18. yep ) sry forgot to take the cash
  19. addCommandHandler( "removeStars", function( thePlayer, cmd ) local stars = getPlayerWantedLevel( thePlayer ) local money = getPlayerMoney( thePlayer ) if ( stars == 1 ) then if ( money >= 100 ) then setPlayerWantedLevel( thePlayer, stars - 1 ) else outputChatBox( "you need more cash!", thePlayer ) end end end )
  20. hm he still doesnt move, i tried for my self and simply setPedControlState with addCommandHandler, doen't work, i think cause the cursor which is activated.. // so debugscript tells me that he can't removeEvenhandler because the ped isn't moving.. ControlState doens't work -.- addEventHandler( "onClientClick", multiData, function( button, state, absX, absY, worldX, worldY, worldZ, element ) if ( button == "left" and state == "down" ) then nx, ny, nz = worldX, worldY, worldZ outputChatBox( "Ped is going" ) addEventHandler( "onClientRender", multiData, setTransformedPosition ) end end ) function setTransformedPosition() local x, y, z = getElementPosition( singleData ) local dist = getDistanceBetweenPoints2D( nx, ny, x, y ) setPedControlState( singleData, "forwards", true ) if ( dist <= 0.2 )then removeEventHandler( "onClientRender", multiData, setTransformedPosition ) outputChatBox( "Ped is gone" ) end end
  21. awesomee. really working :> .. now only problem is the movement with the mouseclick thing.. i don't know how to get and how much the ped must run .. i tried with getKeyState too.. if ( getKeyState( "w" ) )then local x, y, z = getElementPosition( singleData ) setElementPosition( singleData, x + 0.25, y + 0.25, z ) -- rotation -.- end
  22. lollipop. you tried your script? Camera is stucked in player.. and even if i increase the high of the camera, the camera doenst rotate if i press a or d EDIT: We have to work with the "roll" of setCameraMatrix i think! :>
×
×
  • Create New...