Jump to content

kieran

Members
  • Posts

    367
  • Joined

  • Last visited

Posts posted by kieran

  1. @Medwar the first one there DOES set the players stats to max, in San Andreas there is a limit for these skills, if it got current skills and they were 500+ then it worked.  The code is there now you need to go and make something so I can get a better of idea of what you are trying to do, for me that set my full stats.  Go and look at the wiki, see if you can make it work the way you want it to.

    • Thanks 1
  2. @GalactixI read his script wrong, I thought the bracket was at the end of the function...  Nesting is the second example he gave on original post, where you just put the word function under or beside the element that is triggering handler (separated by a comma of course), and then you add a closing bracket at the end of your function, below it or as most do (as it's proper way), you add it to the end of the last end in that function....  If that makes sense.  I forgot to take that line out my post when I edited it. xD

    • Haha 1
  3. 3 hours ago, Galactix said:

    Also make sure if your function is called changenick to use the same name in the handler  and not something like wasNickChangedByUser

    When nesting a function in an event handler like this, don't use the function name.  Just do the following.

    addEventHandler("onPlayerChangeNick", getRootElement(),wasNickChangedByUser)--wasNickChangedByUser is the function name.
    function wasNickChangedByUser()--removed onPlayerChangeNick, within these brackets you only pass returns from event handlers, functions etc.
    	outPutChatBox ( " Your have been changed your nickname " )
    end

    oldNick and newNick are what this event handler returns, an event handler is just something that happens when a player does a certain action (or event) and it handles that event with the function.  So when the function happens the event handler passes the players old name, and new name to the function.  Make sure you check the returns part of wiki page.  Hope that made it a bit clearer to you. :)

  4. 10 hours ago, Yurigarga said:
    
    local tags = {}local fastWrite = {}local someMessage = {} local antiSpam = {}local serials = {}local muteliler = {}local due = {}local ayarlar = { -- meta.xml den çekilen ayarlar	excludedGroups = get"ExcludedGroups" or {},	mesajGorme = get"MesajGorme" or "true",	spamKoruma = get"SpamKoruma" or "true",	kisaltmaMesaj = get"KisaltmaMesaj" or "true",	reklamKoruma = get"ReklamKoruma" or "true",	yasakliKelimeler = get"blacklistedStrings" or {},}addEventHandler('onPlayerChat', root ,function(text,typechat) -- chat eventi	cancelEvent()	local isim = getPlayerName(source)	local r, g, b = getPlayerNametagColor(source) or math.random(0,255), math.random(0,255), math.random(0,255)	local playerTag = playerTagDraw(source)	local randomID = math.random ( 1, #articles )	local article = articles[randomID]	local serial = getPlayerSerial(source)	if serials[serial]  then return end	-- spam protection	if ayarlar.spamKoruma then		if not isPlayerExcluded(source) then			if isTimer(antiSpam[source]) then				cancelEvent()  				spamBlock(source,"Mutele")			else				antiSpam[source] = setTimer(function(player) 					antiSpam[player] = nil 				end, 1000, 1, source) 			end		end		end			-- advertisement protection	if ayarlar.reklamKoruma then		if isAdvertisement(text) then			if not isPlayerExcluded(source) then				for i, yetkililer in ipairs (getElementsByType("player")) do					if isPlayerExcluded(yetkililer) then						if text == article then return end						if ayarlar.mesajGorme then							outputChatBox("#000000[#FF0000WARNİNG#000000] " .. isim ..  " #FF0000the player made an ad: #FFFFFF" .. text, yetkililer, 255, 255, 255, true)							outputServerLog("[ReklamUyari] " .. isim:gsub('#%x%x%x%x%x%x', '') .. ": " .. text)						end					end					end				if giveChance(source) then					text =  article				else					text =  article					spamBlock(source,"Mutele")				end				end			end	end			-- fast write protection    if fastWrite[source] and fastWrite[source]  > getTickCount() then			outputChatBox("write one by one!", source, 255, 0, 0)        return    else        fastWrite[source] = getTickCount()    end		-- someMessage protection    if someMessage[source] and someMessage[source] == text then		outputChatBox("do not write the same words!!", source, 255, 0, 0)		return    else        someMessage[source] = text    end			-- abbreviation message	if ayarlar.kisaltmaMesaj then		for i,v in pairs ( mesajTablo ) do			for k,t in pairs(i) do				if text:lower() == t then					text = v				end			end			end	end			if typechat == 2 then cancelEvent() end -- eğer Y den yazmışsa iptal et		if typechat == 0 then -- eğer T den yazmış ise		if playerYetkilimi(source) then -- eğer player yetkili ise			local tag,chat = playerYetkilimi(source) -- yetkinin tagını ve chat renklerini çek			outputChatBox(tag..isim..chat..text, root, r, g, b, true ) -- chate aktar		elseif playerTag then -- eğer player panelden tag almışsa			outputChatBox(playerTag.." "..isim.."#FFFFFF:#ededed "..text, root, r, g, b, true ) -- chate aktar		else --eğer yukardakilerden ikiside yoksa			outputChatBox(""..isim.."#FFFFFF:#FFFFFF "..text, root, r, g, b, true ) -- chate yolla		end	end		outputServerLog( "CHAT: "  .. isim:gsub('#%x%x%x%x%x%x', '').. ": " .. text )		--exports.ChatBubbles:outputMessage(source, text)end) -- Useful Functions and other eventsfunction playerYetkilimi(player) --player authority function	if isElement(player)  then			local hesapismi = getAccountName(getPlayerAccount(player))		for i,yetkiler in pairs(yetkiliTaglar) do			local acl,tag,chat = unpack(yetkiler)			if aclGetGroup(acl) and isObjectInACLGroup("user." .. hesapismi, aclGetGroup(acl)) then				return tag,chat			end			end		end	return falseendfunction playerTagDraw(player) -- player tag draw function	if tags[player] then		return tags[player]	else		return false	endend	function isAdvertisement(str) -- export function (if the ad is)	assert(type(str) == "string", "Bad argument 1 @ isAdvertisement [String expected, got " .. type(str) .. "]")    local str = string.gsub(str, '#%x%x%x%x%x%x', '')	local workingWord   = string.lower(str):gsub("[_-;:µ|><!^#'%%!§$\\&/()=._-,-#+}{ ]", '').."-";        for index, sBadWord in pairs(ayarlar.yasakliKelimeler) do            local pattern       = workingWord:match(".*"..string.lower(sBadWord).."*.");            if(pattern) then                    return sBadWord            end        end	if str:find("(%d+)%.(%d+)%.(%d+)%.(%d+)") then		return true	end		return falseendfunction isPlayerExcluded(player) -- If the player is authorized	local size = #ayarlar.excludedGroups	if size ~= 0 then		local accountName = getAccountName(getPlayerAccount(player))		for i=1, size do			if isObjectInACLGroup("user." .. accountName, aclGetGroup(ayarlar.excludedGroups[i])) then				return true			end		end	end	return falseendaddEventHandler("onPlayerConnect", root, function(playerNick, _, _, playerSerial, _)  -- player can not run for 10 seconds at server entrance	serials[playerSerial] = true 	setTimer(function() 		serials[playerSerial] = nil	end, 1000*10,1)end)function giveDue(player) -- Forbidden word Give 3 due	if not due[player] then		due[player] = 1		outputChatBox("#FFFFFFyou wrote a forbidden word. #FFFFFFYou have #CC00002 rights .", player, 255,0,0, true)		return true	else		due[player] = due[player]+1		if due[player] and due[player]  > 2 then			due[player] = nil			return false		end		outputChatBox("#FFFFFFyou wrote a forbidden word.. #CC0000"..tostring(due[player]-1).." #FFFFFFHave rights.", player, 255,0,0, true)		return true	endendfunction spamBlock(player,value) -- Spam Blocking Function	local serial = getPlayerSerial(player)	if value == "Mutele" then		outputChatBox(getPlayerName(player).."#CC0000 60 #FFFFFFSaniye Susturuldun. #CC0000Sebep: #FFFFFFFlood/Spam", root, 255,255,255,true) 		setPlayerMuted(player, true)		setTimer (spamBlock, 60000, 1, player, "Mute Kaldır")		muteliler[serial] = true	elseif value == "Mute Kaldır" then			if  isElement (player) and isPlayerMuted (player)  then			setPlayerMuted ( player, false )			antiSpam[player] = nil			muteliler[serial] = false			outputChatBox ("#FFFFFF"..getPlayerName ( player ).." #66FF00Cezan Bitti.",root, 255, 255, 0,true )		else			antiSpam[player] = nil		end	end	endaddEventHandler("onPlayerJoin", root, function() -- while suspended reconnect punished	local serial = getPlayerSerial(source)	if muteliler[serial] then		spamBlock(source,"Mutele")		endend)addEventHandler("onPlayerQuit", root, function()	if tags[source] then tags[source] = nil endend)addEvent("TagPanel:TagAyarla", true)addEventHandler("TagPanel:TagAyarla", root, function(chat,olay)	if olay == "Değiştir" then		tags[source] = chat		outputChatBox("#FFFFFFTagın "..chat.." #FFFFFFolarak değiştirildi", source, 255,0,0, true)	elseif olay == "Sıfırla" then		tags[source] = nil		outputChatBox("#FFFFFFTagını başarıyla sıfırladın.", source, 255,0,0, true)	end	end)

    80% english look again pls 

    Yet I still don't know what you want to do with this script, please explain your goal and then I can see where you are going wrong.

    • Sad 1
  5. @NodZen_42 Try to use getPlayerTeam instead, this is both server and client side, and very reliable.

    local screenW, screenH = guiGetScreenSize()
    
    function drawTheImage ()
    	dxDrawImage(100, 100, 40,40,"mercenarios.png")
    end
    
    function teams_images ()
    	local playersTeam = getPlayerTeam(localPlayer)
    	local TeamName = getTeamName ( playerTeam ) 
    	if TeamName == "Mercenarios" then
    		addEventHandler("onClientRender", root, drawTheImage)
        	outputChatBox('Player is in that team.') --Output a message to check if the script is working and you can't see the image.
    	end
    end
    addEventHandler("onClientPlayerSpawn", getLocalPlayer(),teams_images)

    Apologies if this is wrong, very sleepy.  It is untested but I can test it and try make it work if needed.

    I forgot to mention something VERY important, dx images and anything dx (directX) based, is drawn every frame.  So if you just do it when the player spawns, that image is drawn for 1 frame, not for the duration the player is spawned.  Now to solve this you can use onClientRender, this will check every frame and make sure the image is there, loading it on every frame until you remove the event handler with removeEventHandler.

  6. Is that the whole script?  It seems that you have passed a string to the spamEngelle function, so "oyuncu" is now a string of text and not the player element.  Are you using a command to trigger that function?  Keep in mind I still have no idea at all what you are trying to do with this script...  As I do not speak Turkish.  But I will try and help.

    • Like 1
  7. O.o I not speak the Turkish xD, but if I am correct you are having troubles retrieving a players serial...

    For me your script is EXTREMELY confusing as I only speak English...  So all I can tell you for now is to look at the returns from your event handlers.  That and also to make sure you get the players account/element data (or whatever you use), so that you can pass it into the function.

    Please use /debugscript 3 and then we can get a better idea of the error...  What line is the error coming from?  What error are you getting?  And finally what are you doing when you get this error?  Please write back in English or use google translate. :P

    • Thanks 1
    • Haha 1
  8. You'll need to first create a function before the GUI is created.  Now use GuiGetPosition to get the position of the image clicked (in your new function the image will be the source that triggered it), after this you just destroy the image (in new function) like this: destroyElement (source)

    Why create a function BEFORE the GUI is made I hear you ask?  Well the way a computer reads code is top to bottom, so if you try pass a function, boolean or variable before it knows that it's there, it will get confused and say it's not there.  Simple!

    Now that you have got the position of that image when you clicked it (remember you need "x,y = guiGetPosition (source)"), you can create your new image there.

    If you need an example I can try (please try yourself first), but I am very lazy today.  Also please use these for code '<>' it helps us see your code more clearly as it is colored, just like in notepad++.  I hope this helps you! :D 

  9. 6 hours ago, Galactix said:

    Just use this https://wiki.multitheftauto.com/wiki/SetPlayerStat for all weapons( you could probably gain time with a table or something containing all the IDs) and add an handler « onPlayerSpawn »

    You actually want setPedStat, setPlayerStat is the old one.  And forget the table...  If you just wish to set weapon stats, as I have previously said they are ID's 69-79.

    If you want to SET player stats for all weapons when that player spawns use the following script.

    function setStatsOnSpawn ()
    	for i = 69,79 do --We use a for loop to go through stats 69-79 (all weapon stats you can set)
    		stat = setPedStat ( source, i, 1000 ) --We set the stat to full for the player (1000)
    	end
    end
    
    addEventHandler("onPlayerSpawn", getRootElement(), setStatsOnSpawn) --When player spawns we trigger function

    basically in that for loop i = 69, then the stat for ID 69 is set to 1000.  After that i = 70, and it keeps going until i reaches 79.

    To get all players weapon stats on spawn use the script I posted earlier

    function tellStatsOnSpawn ()
    	for i = 69,79 do --We use a for loop to go through stats 69-79
    		stat = getPedStat ( source, i ) --We get the stat from the source (the player)
    		outputChatBox ( stat, source ) --And we output each stat to players chat 
    	end
    end
    
    addEventHandler("onPlayerSpawn", getRootElement(), tellStatsOnSpawn) --When player spawns we trigger function

    As you can see they are almost identical, but you don't need to get their max stat as we already know:  THE MAX STAT OF ALL SKILLS IS 1000

  10. Yes what that script done was got the players CURRENT weapons stats, not their max weapon stats (I read your post wrong)...  What exactly are you trying to do?  Are you trying to get the max stats for all weapons?  You can only set the stats of the following weapons.

    •  

    Weapon skills:
    Note: see Weapon skill levels for the values that advance weapon skills.

    • 69: WEAPONTYPE_PISTOL_SKILL
    • 70: WEAPONTYPE_PISTOL_SILENCED_SKILL
    • 71: WEAPONTYPE_DESERT_EAGLE_SKILL
    • 72: WEAPONTYPE_SHOTGUN_SKILL
    • 73: WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL
    • 74: WEAPONTYPE_SPAS12_SHOTGUN_SKILL
    • 75: WEAPONTYPE_MICRO_UZI_SKILL
    • 76: WEAPONTYPE_MP5_SKILL
    • 77: WEAPONTYPE_AK47_SKILL
    • 78: WEAPONTYPE_M4_SKILL
    • 79: WEAPONTYPE_SNIPERRIFLE_SKILL

    I was wrong, it seems the max level for all weapons is 999, but the script I had was different...  But please tell me more about what you want to do with your script...  Are you trying to get all weapon stats of all players in game?

  11. Apologies for double post, but the above post can no longer be edited.

    It appears there is no native function to get peds full stat, but after some quick research.  All weapon stats on the getPedStat function have a maximum of 999 skill, except for pistol, sawn-off and micro-uzi which have a max skill of 500.

    So all weapon stat (EXCEPT for stat IDs 69, 73 and 75: Limit for these is 500) have a limit of 999. 

  12. https://wiki.multitheftauto.com/wiki/OnPlayerSpawn

    https://wiki.multitheftauto.com/wiki/GetPedStat (use 69-79)

    From what I understand you want something like this....

    function tellStatsOnSpawn ()
    	for i = 69,79 do --We use a for loop to go through stats 69-79
    		stat = getPedStat ( source, i ) --We get the stat from the source (the player)
    		outputChatBox ( stat, source ) --And we output each stat to players chat
    	end
    end
    
    addEventHandler("onPlayerSpawn", getRootElement(), tellStatsOnSpawn) --When player spawns we trigger function

    I have tested this and it works, but not 100% sure what you want to do.  Note that you will have to get the weapon names/IDs yourself.  If you need help with these functions check wiki links then ask if still stuck, hope it helps. :)

    _________________

    Edit

    Sorry, I misread your post...  This will only get the players current weapon stats, I have no clue how to get the max stat and can't find anything on wiki either.  It might be hard-coded into GTA itself.

  13. I know that this is a nuisance...  But would it be possible to replace the dff, col and txd of 1 single object instead of all objects with that ID?  For example...   If I created an object server side, could I pass that object to the client and only mod that one object?  If not is there a way of adding new model IDs so I could create a new object as if it was from the original GTA list? 

    I ask this as I am planning to modify a lot of objects in game, but only in certain places.  If there is no way to do this, does anyone know where I can find a list of objects that were added to the game but not actually used? 

    Thanks :D

  14. On 6/10/2018 at 16:50, Taurus said:

    you should try to reinstall that script, also it should work normally. ill explain how to export collision. first go to your Utillities, go to Kam's GTA script. press on collision IO, once you have done that. you should see on your left hand side a bar, click on Collision mesh and click on your object (it doesnt matter which object as long as they are connected, also check if your objects x y z are at 0,0,0) and then if you have a car (for example) you can press on shadow mesh and do the same. COL3 should be selected. and then write a name above export. and then export the file.

    PS: download kams script via gtagarage.com

    I have both SA Tools and kams script, there is now no problems with collision files, only dff and txd, check this topic for a more detailed explanation to how I made the object, applied textures etc....  I do not know where I am going wrong :/

     Also thanks for help with kams, that col system confused me a lot.

  15. I have been struggling now for months...  I am trying to just make a simple object, with multiple textures that a player can enter...  The collision (.col) loads fine, and works as expected, there is problems with the texture though and I think it might lay within the dff file when I exported it.

    To make this object I first made 1 floor and 1 wall, I then cloned the wall 3 times to make a box open at the top, I gave each of these cloned objects and the original one a name (front wall, back wall etc).  After this I cloned the floor, I moved it up and cut a hole in the cloned object (now the first floor), I then modified the bottom floor so it had a ramp, made a cut in the front wall so the player could enter, and then I added my images.

    When adding the images, I clicked the little box next to "Diffuse" in the compact material editor, I chose bitmap and imported a .tga image.  I used the same material on the bottom and top floors, a different one for the roof, and also added stairs (just made boxes up to the hole in the top floor) and I COPIED the bitmap using the same .tga and applied tiling to it, I obviously had everything to editable polys, so I selected faces on the outside walls, and applied a brick texture, I then applied another wallpaper texture to the inside (using the tiling function in coordinates to modify it), I also applied tiling to the ramp on the first floor, I detached it and applied the tiling, then attached it again to the original place (copying the floors bitmap once more).  I opened the slate editor and changed the name of all the bitmaps.  I attached all the objects to form one single object, then I exported the DFF and COL with SA Tools, I then use col editor 2 to make the col shape.

    When making the texture (.txd) I just used the images I used in 3DS Max, I gave them the names of the .tga image and set them all to compressed.  But it is still not loading the txd saying there is problems.

    Should I use a different image for each bitmap, or is it okay using the same one with UV tiling for each bitmap?

  16. 4 hours ago, DouglaS666 said:

    I downloaded the resource already with this warning. but I have already removed this line and apparently there are no more errors.

    This brings me back to the same point, what is your goal with this script?  I can't help you until you help me understand what you are trying to do. xD

  17. You have declared "theVehicle" to be a function, it is not a function in your script.   Please tell us what you're trying to do with this script, from what I can see you have tried to bind a key to a vehicle, it MUST be a function or a command.

  18. I have made a simple script to stop people advertising servers, it also converts all caps chat to lower case chat...  There is of course many problems with this.

    Firstly, I need to use outputChatBox and fake the players chats when I convert upper case to lower case, so I need to get their name and output it with the text...  This works okay, but I've noticed the original chat script is a little more complex, it gets the players nametag color and name, and outputs them...  

    Is there a native event to output chat like the player sent it such as: "triggerServerEvent('outputChatBox', localPlayer, some-text)" or do I need to do it the way in the below script?  (see line 25)

    Also when the player uses lower case hexadecimal codes, it thinks that it is part of the text and not a color code, is their a way of ignoring the hex code?  So could I remove the string but also check it's a hex code and not something stupid like '#lol'? 

    My script is below and it is server side for now, but I think it would work better client side (if their is a custom event for outputting chat)

    strings = {
    	--try entering "mtasa" or "server" in game and see what happens!
    	{'mtasa://', 'DO NOT ADVERTISE IP!'}, --string_to_find[1], message_to_show_player[2]
    	{'SERVER', 'DO NOT ADVERTISE SERVERS!'}, 
    }										
    
    function checkText( message, messageType )
        if messageType == 0 then
    		for i=1,#strings do
    			string_to_find = strings[i][1]
    			message_to_show_player = strings[i][2]
    			findstring = string.find(tostring(string.upper(message)),tostring(string.upper(string_to_find)))
    			if findstring then
    				cancelEvent()
    				outputChatBox(tostring(message_to_show_player), source, 255, 0, 0)
    				return false --stops here if player is advertising, otherwise it will check for caps in chat.
    			end
    		end
    	--Below is anti-caps script
    	capsfree = string.match(tostring(message), '%l')
    	local name = getPlayerName ( source )
    	
    	if not capsfree then 
    		cancelEvent()
    		outputChatBox(tostring(name)..': #E7D9B0'..string.lower(message), _,231,217,176,true) --HERE is where I want to make it as if the player sent the chat
    	end --anti-caps ends here
    	end
    end
    
    addEventHandler("onPlayerChat", root, checkText)

    Thanks for any help in advance. :)

  19. Sorry can't edit last post, but now I want to take it further and convert uppercase letters to lowercase, I've done this and it works with %l, my issue is that I don't know how I'd send it as if the player typed it to all other players, is there a native function to output a message like this or would I need to get the players name and tag color and do it manually?  I know I can do just "outputChatBox(message)"  on server side and all will see it, but would I need to add name and color to the start of that message?  Or is their an easier way?

    function checkCaps( message, messageType )
        if messageType == 0 then
    		capsfree = string.match(tostring(message), '%l') --%l will check for lower case letters
    		if not capsfree then --If there is no lower case letters
    			cancelEvent()
    			outputChatBox(string.lower(message)) --Then convert the string to lower case
    		end
    	end
    end
    
    addEventHandler("onPlayerChat", root, checkCaps)

     

  20. @Fist Thanks so much!  For anyone wanting a sort of early version of the script I'm making or that's struggling for an answer, here is the working code.

    strings = {
    	{'mtasa://', 'DO NOT ADVERTISE'}, --tablesting[1], outputmessage[2]
    }
    
    function checkText( message, messageType )
        if messageType == 0 then
    		for i=1,#strings do 
    			tablestring = strings[i][1]
    			outputmessage = strings[i][2]
    			findstring = string.find(tostring(message),tostring(tablestring))
    			if findstring then
    				cancelEvent()
    				outputChatBox(tostring(outputmessage), source, 255, 0, 0)
    			end
    		end
    	end
    end
    
    addEventHandler("onPlayerChat", root, checkText)

     

×
×
  • Create New...