Jump to content

jkub

Members
  • Posts

    342
  • Joined

  • Last visited

Everything posted by jkub

  1. I was finallly able to test this with another couple of players in my server using the name method and it did work for each person BUT I beilive my current problem may be a sync problem. At first when you just start using the script it shoots out only 1 marker for each shot you fired but as you go on it will sometimes shoot out 2 at a time for each shot. For each extra marker that comes out ( for example you shoot once and 2 comes out ) when you detonate it only one of them will explode leaving another marker permenently stuck. I beilive I didn't intend on this and see no suspected code capeable of this in my script. I do know that I am creating all those markers server side though and that may be adding to the problem. Can making the markers client fix that entire problem?
  2. I used this to set the element data setElementData ( beacons[ballCount].ball, "owner", getPlayerName(client) ) and later on in the detonation function I try to use this to retrieve it local ownerName = getElementData ( beacons, "owner" ) The setelement data works fine ( no errors ) but getELementData line returns a bad argument every time any suggestions? EDIT: I just now tried out "beacons[k].ball" and it returns no errors and it does actually explode but I do not have anyone else in my server to test it with to make sure... Does it look right?
  3. Ive seen the paintball script and another similar small script that adds explosions to wherever you shoot. I wanted to make somthing similar that allows you to shoot white orbs and when shot at vehicles or players it will stick to them. Later on you can use a command or other method of input to detonate the orb ( explosion ). I successfully did that with help of references of other great scripts. There is a limit of how many orbs can be deployed at once I have it set to 20. Whenever anyone types the special command to detonate the orbs It will detonate every single orb that has been deployed even if that person has not deployed any orbs theirselves. So basicly I will have people running around detonating other peoples orbs. I dont want that, I want it to where they detonate their OWN orbs. I have no clue how to do this with multiple elements in a table since there will be multiple orbs. I thought of client explosions but then that would just be for one person and it would defeat the whole purpose of everying being able to be affected by the explosion Here is some of my code Server addEvent ( "clientFire", true ) addEventHandler ( "clientFire", getRootElement(), function ( x, y, z, hitElement, weapon, size, expType ) if ballCount < 20 then beacons[ballCount] = {} beacons[ballCount].ball = createMarker ( x, y, z, "corona", size, 255, 255, 255, 255, getRootElement() ) local x, y, z = getElementPosition ( beacons[ballCount].ball ) if hitElement then if getElementType ( hitElement ) == "vehicle" or getElementType ( hitElement ) == "player" then attachElements ( beacons[ballCount].ball, hitElement, 0, 0, 0 ) end end explosionNumber = tonumber(expType) ballCount = ballCount + 1 elseif ballCount == 20 then playSoundFrontEnd ( client, 41 ) outputChatBox ( "Hax limit reached: Explode your current Hax", client, 255, 0, 0 ) end end ) addCommandHandler ( "det", function ( player, cmd ) if beacons then for k,v in pairs ( beacons ) do local x, y, z = getElementPosition ( beacons[k].ball ) createExplosion ( x, y, z, explosionNumber, player ) destroyElement ( beacons[k].ball ) beacons[k] = {} ballCount = 0 end end end Can I please get some help with this
  4. jkub

    job :(

    the above post seems just fine to me but you might wanna try making the function name (startbus) different from the command name(startbus)
  5. jkub

    Alert Strip

    I wrote this off top. In the meantime I guess you can try this. server script function randomFunctionName ( ammo, killer, weapon, bodypart ) triggerClientEvent ( "server_PlayerDied", killer, getPlayerName(killer), getPlayerName(source) ) end addEventHandler ( "onPlayerWasted", getRootElement(), randomFunctionName ) client script addEvent ( "server_PlayerDied", true ) local delay = 2500 addEventHandler ( "server_PlayerDied", getRootElement(), function ( killerName, victimName ) guiSetText ( whateverYourTextElementInYourGuiWindowIsCalled, tostring(victimName).. " has died!" ) setTimer ( guiSetText, delay, 1, whateverYourTextElementInYourGuiWindowIsCalled, "" ) end )
  6. I used 50p's method of multiplying by 100 and eAi's "%d" suggestion. It worked Perfectly! This is exactly what I was wanting I have been wondering this for so long. Ill take a look at that page and try to interpret:) Thanks so Much Guys!
  7. Im making a compact speedometer script for experimentational purposes. I know there are is already a selection of speedometers uploaded but I want to learn a basic one myself. I calculated the speed and other things correctly but my main problem here is that I am almost clueless when it comes to manipulating strings. I have did something quite similar to this before and now instead of a "minute.second" format im gonna need a mph format for example "248" Right now I just get "2.48" Ive tried looking at string.sub and string.format in the lua website but I cant get much out of it. However the only thing I am or seem to be understanding is the number that I put in will change the amount of visible charecters. For example "speedStr = string.format ( "%.2f", speedSub )" that two allows me to get somthing like this 2.48 where if I changed it to 3 I would get something like 2.485(some other number) It says there I can use different letters and only two charecters are for strings. I have no clue what each of them does all though Ive tried all of them to see if I could get lucky... No luck Here is some of the code function calculateSpeedAndHealth() local clientVeh = getPedOccupiedVehicle ( getLocalPlayer() ) local velX, velY, velZ = getElementVelocity ( clientVeh ) local realSpeed = ( velX^2 + velY^2 + velZ^2 )^( 0.5 ) -- local vehHealth = getElementHealth ( clientVeh ) -- speedSub = string.sub ( realSpeed, 1, 4 ) speedStr = string.format ( "%.2f", speedSub ) healthString = string.sub ( vehHealth, 1, 3 ) guiSetText ( speedNumber, "Mph: " ..speedStr ) if ( vehHealth >= 1000 ) then guiSetText ( healthNumber, "Health: 1000" ) else guiSetText ( healthNumber, "Health: " ..healthString ) end if isPedInVehicle ( getLocalPlayer() ) then -- else guiSetVisible ( speedometer, false ) removeEventHandler ( "onClientRender", getRootElement(), calculateSpeedAndHealth ) end end You can also see I used string.sub which from what I understands does ALMOST the same thing as that number I mentioned that changed the ammount of numbers Please help me with this
  8. I am gonna make you an offer you can't refuse
  9. jkub

    help on a bombshop

    Thanks:) I tried this and studied some other scripts closely to get more understanding of the elementData part I can use to define the time settings. I went ahead and did a collision sensor thingy with this and it works! ( with 1 small bug ) Thanks Ive also rewrote the gui to where all gui clicks are on one function. Looks much neater now
  10. jkub

    help on a bombshop

    As soon as the player clicks the ok button on the time modifier window for that section I do not want it armed instantly. Instead I want the script to be able to store the time that the person put in and later when they type a command to arm it then it would be able to arm then blow up after their time they set. Thats my problem. I dont know how to keep the data in their long enough so whenever I get to the function that actually arms the bomb and is about to blow up It does not know what the time setting is and it comes up with nil. triggerevent would not apply due to the fact that it would instantly trigger the function that arms the bomb. and the person would not even type the arm command. Im sorry if this comes unclear lol. Kind of hard to explain
  11. I am making a multi function bomb shop and I need some help with the time bomb part. It has a window for setting your own time for the car to blow up but I do no know how to pass the data from the function that retrives the data from the input field into the function that arms the bomb and tells it when to blow up. The only way I can do it right now is with this command /arm I want to be able to use my time window I made in the gui to tell how long the time will be plz help me this is server part function armTimeBomb ( player, cmd, timeSetting ) local veh = getPedOccupiedVehicle(player) if isPedInVehicle ( player ) then if getElementData ( veh, "rigged", true ) then setTimer ( blowVehicle, tonumber(timeSetting), 1, veh ) outputChatBox ( "Go Boom in " ..timeSetting ) end end end addEventHandler ( "clientSetTimeBomb", root, function ( timeSetting ) timeSetting = timeSetting takePlayerMoney ( client, 350 ) outputChatBox ( "You have purchased a Time Bomb. To arm the bomb type /arm", client, 0, 255, 0 ) outputChatBox ( timeSetting ) addCommandHandler ( "arm", armTimeBomb, tonumber(timeSetting) ) end ) --TIME BOMB function clientTimeBomb() if ( getPlayerMoney ( client ) >= 350 ) then if isPedInVehicle ( client ) then local clientVeh = getPedOccupiedVehicle ( client ) if getElementData ( clientVeh, "rigged", true ) then outputChatBox ( "ERROR: This vehicle is already rigged", client, 255, 0, 0 ) else setElementData ( clientVeh, "rigged", clientVeh ) setElementData ( clientVeh, "timebomb", clientVeh ) triggerClientEvent ( client, "showTimeModifier", client ) end end end end --TIME BOMB
  12. jkub

    Ped Help

    They have that function for peds?
  13. jkub

    Ped Help

    I need a ped behind the ammunation counter so when someone shoots at him he can shoot back at the attacker just like in the normal game. I already created the ped and placed him behind the counter but the code does not work right for shooting the attacker. Please help? function pedDefend ( attacker, weapon, bodypart ) local x, y, z = getElementPosition ( attacker ) setPedWeaponSlot ( source, 3 ) setPedAimTarget ( source, x, y, z ) setPedLookAt ( source, 0, 0, 0, 999999, attacker ) setTimer ( setPedControlState, 200, 0, source, "fire", true ) end addEventHandler ( "onClientPedDamage", getRootElement(), pedDefend )
  14. can callClientFunction be a good alternative to triggerClientEvent?
  15. jkub

    Headlight Gui Help

    Wow I never knew about that. I guess ill take a look at it later:)
  16. jkub

    Headlight Gui Help

    Everything is wrote down correct no typos. But 50p >> When I made this I did with the help of gui-classes. I used the :AddTextBox custom function made for it. Some odd reason when I replaced that function with the original function guiCreateEdit... It worked. Is there a special way to make it work using gui-classes?
  17. jkub

    Headlight Gui Help

    I did that outputChatBox on the client side and it also said "false" x3 for my color values.
  18. jkub

    Headlight Gui Help

    I used outputChatBox and tostring to show what I had for clientVehicle and the three custom color values for clientvehicle it said "userdata: 000000F4" and for all three color values it said "false"
  19. jkub

    Headlight Gui Help

    Yes I did and it said attempt to concatenate number values
  20. jkub

    Headlight Gui Help

    it says userdata but I used triggerClientEvent from the server I used an example from the wiki and altered the data to suit what I was trying to do.
  21. jkub

    Headlight Gui Help

    Is this what you meanVV addEventHandler ( "clientCustom", getRootElement(), function ( red, green, blue ) clientVeh = getPedOccupiedVehicle ( client ) setVehicleHeadLightColor ( clientVeh, tonumber(red), tonumber(green), tonumber(blue) ) end ) Ive tried that^^ and does not work... that way and the way I had before that gives the same error in the debug saying that my setVehicleHeadLightColor is a bad argument
  22. I am working on a simple Gui menu for editing headlight colors. I think my problem is that im not passing the data from the client to the server correctly. I got buttons for common colors and I got text fields so you can make your own color. I use guiGetText to get whatever is in the text fields. Here is some code im using Here is a client side method I tried function selectCustom () r = guiGetText ( cstFieldRd ) g = guiGetText ( cstFieldGrn ) b = guiGetText ( cstFieldBlu ) triggerServerEvent ( "clientCustom", getRootElement(), r, g, b ) end Here is another client method I tried function selectCustom () triggerServerEvent ( "clientCustom", getRootElement(), guiGetText(cstFieldRed), guiGetText(cstFieldGreen), guiGetText(cstFieldBlue) ) end Here is a server method I tried to recieve the data addEventHandler ( "clientCustom", getRootElement(), function ( red, green, blue ) clientVeh = getPedOccupiedVehicle ( client ) setVehicleHeadLightColor ( clientVeh, red, green, blue ) end ) I thought that when you pass data from client to server using triggerServerEvent that whatever element or argument you pass will automaticly be one of the arguments inside the function ( ) Can you help me please?
  23. If there are so many teams then we need to know how many teams there are so we know how big to make the window.
  24. jkub

    Bind key

    Try this. As for disabling the other keys in the freeroam script I think youd have to do that manualy But here the toggles are I guess:) function toggleEngine ( thePlayer ) local isOn = getVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer) ) if isPlayerInVehicle ( thePlayer ) then if isOn == true then setVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer), false ) outputChatBox ( "*Engine off*", thePlayer ) elseif isOn == false then setVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer), true ) outputChatBox ( "*Engine on*", thePlayer ) end end end function toggleJetpack ( thePlayer ) local hasJetpack = doesPlayerHaveJetpack ( thePlayer ) if isPlayerInVehicle ( thePlayer ) then --... else if hasJetpack == true then removePlayerJetPack ( thePlayer ) outputChatBox ( "*Jetpack removed*", thePlayer ) elseif hasJetpack == false then givePlayerJetPack ( thePlayer ) outputChatBox ( "*Jetpack equip*", thePlayer ) end end end function bindControls ( ) bindKey ( thePlayer, "o", "down", toggleEngine ) bindKey ( thePlayer, "f", "down", toggleJetpack ) end addEventHandler ( "onPlayerSpawn", getRootElement(), bindControls )
×
×
  • Create New...