-
Posts
1,803 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Citizen
-
Ok, can you please paste your code for the blips please ?
-
Maybe this ? function someoneReachedHunter(number, sort, model) -- get the element data gotHunter to check if he already got it once local alreadyGotHunter = getElementData(source, "gotHunter") if sort == "vehiclechange" and model == 425 and not alreadyGotHunter then outputChatBox ( getPlayerName(source).." #3366FFhas taken the hunter and gets #B30000$500!", getRootElement(), 255, 255, 255, true ) givePlayerMoney ( source, 500 ) --set the element data gotHunter to true to know he got it for the 1st time on this map end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup", root, someoneReachedHunter) -- reset gotHunter element data for everyone when the new map is starting addEvent("onMapStarting", true) function resetHunterStatus() for k, player in ipairs(getElementsByType("player")) do setElementData(player, "gotHunter", false) end end addEventHandler("onMapStarting", root, resetHunterStatus)
-
Not really, when the last player of a vehicle just left it, the timer should be created to respawn that vehicle if nobody has entered in it after 1 minute: function isVehicleEmpty( vehicle ) if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then return true end local passengers = getVehicleMaxPassengers( vehicle ) if type( passengers ) == 'number' then for seat = 0, passengers do if getVehicleOccupant( vehicle, seat ) then return false end end end return true end local RESPAWN_TIME = 1 --Time in minutes function watchForEmptyVehicle() for k, veh in ipairs (getElementsByType("vehicle")) do local respawnTimer = getElementData(veh, "respawnTimer") local isEmpty = isVehicleEmpty(veh) if isEmpty and not respawnTimer then local respawnTimer = setTimer(respawnVehicle, RESPAWN_TIME*60*1000, 1, veh) setElementData(veh, "respawnTimer", respawnTimer) elseif not isEmpty and respawnTimer then killTimer(respawnTimer) setElementData(veh, "respawnTimer", false) end end end setTimer(watchForEmptyVehicle, 5000, 0) (I didn't use the events onPlayerVehicle(Exit/Enter) because I didn't know what would return isVehicleEmpty if someone carjack partially (just kicking the driver out) or completly (really stole the car). So I used a setTimer)
-
Hi, On client side: First you can remove the lines 32 and 33 since it just can't work and you are already showing properly the gui somewhere else. Then I would suggest you to replace the name of the unpackRobberHouses function by getRandomHousePosition. It has nothing to do with the solution but it's probably more explicit on what the function is doing. (Note: that I'm using this new name in the code below.) Then replace the lines 80 to 86 to be like this: addEvent("HaveCriminalJob", true) function startCriminalJob() outputChatBox("The job has started, go on the marker ...") createRandomHouse() end addEventHandler("HaveCriminalJob", root, startCriminalJob) addEvent("createHouseEvent", true) function createRandomHouse () local x, y, z = getRandomHousePosition() robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85 ) robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32 ) outputChatBox("Created marker at: "..tostring(x)..", "..tostring(y)..", "..tostring(z)) end addEventHandler ( "createHouseEvent", root, createRandomHouse ) You weren't "catching" the HaveCriminalJob triggered from server-side after the player got the job so I created the startCriminalJob function instead of adding createRandomHouse as an handler of this event because you would probably want to do stuff only when he is starting the job (as example, I added an outputChatBox. Then, you didn't get that a function available on both sides can have 2 different syntaxes. You used the server syntax for createMarker and createBlipAttachedTo functions on the client-side. We don't need to specify the player for who it should be visible because everything that is created on the client-side is only visible for that client. Also, I added an extra outputChatBox for debugging purposes. You can save a lot of times by using such functions to print where the code is going and where it is stopping. On the server-side: Everything is fine. In the end, I would suggest you to learn about local variables. You should use the local variable as often as possible. For example on the server-side at line 9: There is no need for the money variable to be a global one (accessible outside the the function in this case). You just can use the local keyword because you only need it inside that function: local money = math.random ( 150, 2500 ) It will works just fine and the variable will be deleted at the end of the scope (the function in this case).
-
By that, he means that you have to add your resource to the Admin group in acl.xml (located at the same place as mtaserver.conf) <acl> ... <group name="Admin"> ... <object name="resource.yourResourceName" /> ... </group> ... </acl> More information about acl here: https://wiki.multitheftauto.com/wiki/Access_Control_List
-
I really don't understand the position and size calculation in this code, it's kinda different from the blip one but it should looks like the same. Specially this: dxDrawRectangle(radarX, radarY, rw/2, -rh/2, tocolor(rr, rg, rb, ra), false) why -rh/2 ? is it like a random fix you tried ? If yes, then remove it in my code too (replace - by a + on line : local radarX = ((rmapX+(rmapW/2))+cradarx) local radarY = ((rmapY+(rmapH/2))+cradary) -- keep the position inside radarX = math.max(rmapX, math.min(rmapX + rmapW, radarX)) radarY = math.max(rmapY , math.min(rmapY + rmapH, radarY)) -- keep the size inside local radarW = math.max(rmapX, math.min(rmapX + rmapW, rmapX + rw/2)) local radarH = math.max(rmapY , math.min(rmapY + rmapH, rmapX - rh/2)) if (isRadarAreaFlashing(radar)) then ra = ra*math.abs(getTickCount()%1000-500)/500 end dxDrawRectangle(radarX, radarY, radarW, radarH, tocolor(rr, rg, rb, ra), false)
-
Ok lol so first, it's not a proper way to ask help to a community ... For me it's just like if you threw your dirty clothes on your mom face to make her wash them. You would never do that so it's the same here. It's really disrespectfull. Even if you don't speak in english well, it's easy to say something like: "Hello everyone, I have a problem with my code. I want to add the clantag "3R//" to the players in my list if they don't have it yet. Here is the code:" And only after said that you can paste your code between lua tags and also give us the errors from the server console or from /debugscript 3 (you need to be logged in) if there are any. That said, I saw your script and I think I understood what you were trying to do. So here is it: local clanTag = "3R//" local clanPlayers = { "Name1", "Name2", "Name3" } local colorCodeRed = {255, 0, 0} local colorCodeGreen = {0, 255, 0} local colorCodeBlue = {0, 0, 255} setTimer(function() for k, player in ipairs (getElementsByType("player")) do if isInClan(player) and not hasClanTag(player) then setPlayerName(player, clanTag..getPlayerName(player)) end end end, 5000, 0) function hasClanTag(player) local name = getPlayerName(player) if name and string.find(name, clanTag) then return true end return false end function isInClan(player) local name = getPlayerName(player) or "" for i, v in ipairs (clanPlayers) do if name == clanPlayers[i] then return true end end return false end
-
Ok lol, just calm down Deepu stop arguing with members who want to help you. Don't you think that at this moment YOU and not us is the problem ? Because we still don't understand what you actually want to do after 7 posts from you. Call other "son" because someone treats you as a beginner (and sorry, but you're still a beginner and you're really close to your 61% of your signature) is disrespectful. Nobody will help you more if you are talking to them like you just do. And about your problem of your marker position you want to be updated to make it follow the player on his right (that's what I understood so far) use this function and call it with a setTimer: https://wiki.multitheftauto.com/wiki/Get ... ceRotation X and Y will be the current player position, the distance will be 8 and angle will be 90 (means right).
-
To make everything clear, here is one of the code you should end with: Server: local _setPlayerMuted = setPlayerMuted function setPlayerMuted( player, state ) if ( isElement( player ) ) and ( getElementType( player ) == "player" ) and ( type( state ) == "boolean" ) then if ( _setPlayerMuted( player, state ) ) then if ( state ) then setElementData( player, getResourceName( resource ) .. ":muted", true, true ) else if ( getElementData( player, getResourceName( resource ) .. ":muted" ) ) then removeElementData( player, getResourceName( resource ) .. ":muted" ) end end return true end end return false end addEventHandler("onPlayerMute", root, function() setPlayerMuted(source, true) end) addEventHandler("onPlayerUnmute", root, function() setPlayerMuted(source, false) end) Client: local screen_width, screen_height = guiGetScreenSize( ) addEventHandler( "onClientRender", root, function( ) local is_muted = getElementData( localPlayer, getResourceName( resource ) .. ":muted" ) local mute_text = "Mute: " .. ( is_muted and "Yes" or "No" ) local mute_width, mute_height = dxGetTextWidth( mute_text, 2.0, "default" ), dxGetFontHeight( 2.0, "default" ) dxDrawText( mute_text, screen_width - mute_width - 24, ( screen_height - mute_height ) / 2 + 1, screen_width, screen_height, tocolor( 0, 0, 0, 150 ), 2.0, "default", "left", "top", true, false, post_gui, false, false ) dxDrawText( mute_text, screen_width - mute_width - 25, ( screen_height - mute_height ) / 2, screen_width, screen_height, tocolor( 255, is_muted and 0 or 255, is_muted and 0 or 255, 230 ), 2.0, "default", "left", "top", true, false, post_gui, false, false ) end ) There is no reason it shouldn't work (restart the right resource, not admin one)
-
this if statement: if isElementWithinMarker(hitElement) then end is totally useless for two reasons: 1 - this condition is wrong since this function takes 2 arguments (theElement, theMarker) 2 - It will always return true because you are checking if the element that entered into the marker is in the marker. Ofc he is in, he just entered in it. I also wonder why do you want to do it on the client-side ?
-
I didn't get what you said, but what I tried to say is that your original code would work with these values: local x1 = -1195 local y1 = -1063.5 local x2 = -1003.2 local y2 = -1163.5 Since it was a rectangle, there is nothing complicated, I dunno why you talked about a formula with roots in it.
-
That's what should do the new setPlayerMuted myonlake made. That's why I directly used that function again to let it set the element data.
-
You can download and use a packet sniffer tool in just a few seconds, since http downloads are not encrypted. The best way to make sure that nobody steals your scripts is by making a custom downloader script that sends client scripts using triggerClientEvent since packets are then encrypted, and do loadstring on the code instead of saving onto a file. I'm agree, see this post: viewtopic.php?f=108&t=29990#p337791
-
Please Read My first Post Again I don't see any code or link to a resource. Do you ?
-
Oh you are muing from the admin panel ?! That's what you should say at the very begining of this thread. No one knew that ! Just add these lines on the server side but keep the myonlake's solution you selected. Server: addEventHandler("onPlayerMute", root, function() setPlayerMuted(source, true) end) addEventHandler("onPlayerUnmute", root, function() setPlayerMuted(source, false) end)
-
Ok and what about the code/resource link ?!
-
Just use a timer then ? setTimer Note: dxDrawText isn't updating itself. Ht has to be used in a function attached to the onClientRender event which is like a really fast timer (faster that you can do with the setTimer function).
-
Show us the code of the vehicle shop (when you buy a vehicle) or if it's a resource you downloaded, the link to that resource. Also show us the code of the gridlist you want to add cars into. And please, can you explain better what you want your script to do (step by step if needed). What do you mean by hide and mark a car ??
-
1 - what are the problems, we can't see them if you don't show them to us. 2 - you have at least 4 working code on the previous page. Are you sure you know where to put this code ?
-
He mean't with the rotation ... Because getElementRotation is the right function but you said it is not because you can't update it, so what do you mean by that ?
-
Did you really read my post ??
-
I Don't think that people on this forum are slaves,the ? I just didn't write anything about it because i didn't know what to because its a bit obvious what i was trying to do. also on error output it didn't say anything about 2nd argument,and don't call me lazy for no reason. This is what I call a proper way to ask: "Hello everyone, I have a problem with this script. I'm trying to add a command which spawns a vehicle of the desired model and warp the player into that vehicle. Here is the script:" "And the server gives me this error: " By watching your post, I see that the guy who created the thread was so lazy he didn't even say "hi", we are humans so yeah ... Sorry if it's not what you wanted to show, but that's how I saw it.
-
I know you already solved the problem but you both didn't what was the problem and here it is: local y1 = -1063.5 local y2 = -1065.5999755859 As you can see, the y2 is too close from the y1 (only 2 meters, which is really small in GTA SA). Your code would work if you had the right position for y2 (or maybe y1 ?).