-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
You should learn to do that by yourself as it's really easy to, but this time I'll do it. addEventHandler("onPlayerLogin",getRootElement(), function () local account = getPlayerAccount(source) local kills = getAccountData(account,"kills") local deaths = getAccountData(account,"deaths") local headshots = getAccountData(account,"headshots") if not kills then setAccountData(account,"kills",0) end if not deaths then setAccountData(account,"deaths",0) end if not headshots then setAccountData(account,"headshots",0) end end) addEventHandler("onPlayerJoin",root, function () bindKey(source,"F7","down",getPlayerStats) end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"F7","down",getPlayerStats) end end) function updatePlayerStats(ammo, attacker, weapon, bodypart) updateAccountData(getPlayerAccount(source), "deaths", 1) if attacker or attacker == source then local account = getPlayerAccount(attacker) if account and attacker and getElementType(attacker) == "player" then updateAccountData(account, "kills", 1) if bodypart == 9 then updateAccountData(account, "headshots", 1) end end end end addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) function getPlayerStats(thePlayer) local account = getPlayerAccount(thePlayer) if not isGuestAccount(account) then local kills = getAccountData(account,"kills") or 0 local headshots = getAccountData(account,"headshots") or 0 local deaths = getAccountData(account,"deaths") or 0 local ratio = string.format("%.2f", kills / deaths) outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) else outputChatBox("[sTATS] You must be logged in able to see your stats.",thePlayer,255,0,0) end end addCommandHandler("stats",getPlayerStats) function updateAccountData(account, dataName, toUpdate) if account then local oldData = getAccountData(account,dataName) setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) end end
-
Ok, here. addEventHandler("onPlayerLogin",getRootElement(), function () local account = getPlayerAccount(source) local kills = getAccountData(account,"kills") local deaths = getAccountData(account,"deaths") local headshots = getAccountData(account,"headshots") if not kills then setAccountData(account,"kills",0) end if not deaths then setAccountData(account,"deaths",0) end if not headshots then setAccountData(account,"headshots",0) end end) addEventHandler("onPlayerJoin",root, function () bindKey(source,"F7","down",getPlayerStats) end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"F7","down",getPlayerStats) end end) function updatePlayerStats(ammo, attacker, weapon, bodypart) updateAccountData(getPlayerAccount(source), "deaths", 1) if attacker or attacker == source then local account = getPlayerAccount(attacker) if account and attacker and getElementType(attacker) == "player" then updateAccountData(account, "kills", 1) if bodypart == 9 then updateAccountData(account, "headshots", 1) end end end end addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) function getPlayerStats(thePlayer) local account = getPlayerAccount(thePlayer) if account then local kills = getAccountData(account,"kills") or 0 local headshots = getAccountData(account,"headshots") or 0 local deaths = getAccountData(account,"deaths") or 0 local ratio = string.format("%.2f", kills / deaths) outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) end end addCommandHandler("stats",getPlayerStats) function updateAccountData(account, dataName, toUpdate) if account then local oldData = getAccountData(account,dataName) setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) end end
-
Do you mean like a vehicle spawner trainer? if so, MTA doesn't allow that.
-
Teams={ {"Demonic God's Team", "|DGT|", "#0000ff"}, } function ResourceStart(p) for i,data in pairs(Teams) do if not isElement(data[1]) then team = createTeam(data[1], getColorFromString(data[3])) end if string.find ( getPlayerName(p),data[2]) then setPlayerTeam(p,team) outputChatBox("ok") end end end addCommandHandler("teama",ResourceStart) I think your main error was that you we're checking if the team name string was a "team", which is impossible because it was not an element.
-
Try using this instead: addEventHandler("onPlayerLogin",getRootElement(), function () local account = getPlayerAccount(source) local kills = getAccountData(account,"kills") local deaths = getAccountData(account,"deaths") local headshots = getAccountData(account,"headshots") if not kills then setAccountData(account,"kills",0) end if not deaths then setAccountData(account,"deaths",0) end if not headshots then setAccountData(account,"headshots",0) end end) function updatePlayerStats(ammo, attacker, weapon, bodypart) updateAccountData(getPlayerAccount(source), "deaths", 1) if attacker or attacker == source then local account = getPlayerAccount(attacker) if account and attacker and getElementType(attacker) == "player" then updateAccountData(account, "kills", 1) if bodypart == 9 then updateAccountData(account, "headshots", 1) end end end end addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) function getPlayerStats(thePlayer) local account = getPlayerAccount(thePlayer) if account then local kills = getAccountData(account,"kills") or 0 local headshots = getAccountData(account,"headshots") or 0 local deaths = getAccountData(account,"deaths") or 0 local ratio = string.format("%.2f", kills / deaths) outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) end end addCommandHandler("stats",getPlayerStats) function updateAccountData(account, dataName, toUpdate) if account then local oldData = getAccountData(account,dataName) setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) end end
-
I don't know then, works perfectly here.
-
You have taken this from another topic, but you forgot to remove code line numbers... post the original topic link.
-
That's the same I last posted but without the variable, and my code was working, I tested it.
-
Ok, I get what you was trying to do now, but your problem was that you put infoMemo as a string. root = getRootElement() sx,sy = guiGetScreenSize() addCommandHandler("shop",function() shop = {} shop['window'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"Shop",false) shop['info1'] = guiCreateMemo(0.3644,0.1812,0.4759,0.3068,"",true,shop['window']) shop['info2'] = guiCreateMemo(0.3644,0.6039,0.4759,0.3068,"",true,shop['window']) end ) function itm1(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",1) setElementData(btn,"info",info) end function itm2(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",2) setElementData(btn,"info",info) end function loadShop() itm1(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end function getItemInfo() if getElementData(source,"info") then local infoindex = getElementData(source,"infoindex") local info = getElementData(source,"info") local infoMemo = shop["info".. infoindex] guiSetText(infoMemo,info) end end addEventHandler("onClientMouseEnter",root,getItemInfo) Should do what you wanted now.
-
You are using a variable as a gui-element, which won't work of course. root = getRootElement() sx,sy = guiGetScreenSize() addCommandHandler("shop",function() shop = {} shop['window'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"Shop",false) shop['info1'] = guiCreateMemo(0.3644,0.1812,0.4759,0.3068,"",true,shop['window']) shop['info2'] = guiCreateMemo(0.3644,0.6039,0.4759,0.3068,"",true,shop['window']) end ) function itm1(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",1) setElementData(btn,"info",info) end function itm2(x,y,w,h,text,info) local btn = guiCreateButton(x,y,w,h,text,true,shop['window']) setElementData(btn,"infoindex",2) setElementData(btn,"info",info) end function loadShop() itm1(0.1714,0.1787,0.1597,0.0652,"Flip","Flip your car for $500") -- this for test end function getItemInfo() if getElementData(source,"info") then local infoindex = getElementData(source,"infoindex") local info = getElementData(source,"info") local infoMemo = "shop['info"..infoindex.."']" guiSetText(shop['info1'],info) end end addEventHandler("onClientMouseEnter",root,getItemInfo) Not sure if that's waht you wanted.
-
function actualizarPosicionSonido( sound, vehicle ) if sound and vehicle then x, y, z = getElementPosition( vehicle ) setElementPosition( sound, x, y, z ) end end function getSoundPath( id ) if id == 1 then return "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX" elseif id == 2 then return "http://194.169.201.177:8085/live3.mp3" elseif id == 3 then return "http://194.169.201.177:8085/liveDial.mp3" elseif id == 4 then return "http://194.169.201.177:8085/liveser.mp3" elseif id == 5 then return "http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u" elseif id == 7 then return "http://streaming.tst.es/stcasx/va90winlive2001/play.asx" end end sound = {} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then outputChatBox(tostring(id)) outputChatBox(tostring(getPlayerName(player))) x, y, z = getElementPosition( veh ) path = getSoundPath( id ) sound[player] = {} sound[player].theSound = playSound3D( path, x, y, z, false ) sound[player].path = path sound[player].x = x sound[player].y = y sound[player].z = z if volumebar then volume = guiScrollBarGetScrollPosition (volumebar) / 50 else volume = 2.5 end sound[player].volume = volume sound[player].timer = setTimer( actualizarPosicionSonido, 50, 0, sound[player].theSound, getPedOccupiedVehicle( player ) ) setSoundMaxDistance( sound[player], maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ player ] ) killTimer( sound[player].timer ) sound[ player ] = nil setElementData( player, "radio", false ) end end ) Tell me if it outputs the sound ID and the player name to chatbox.
-
Maybe, post the server side part.
-
Strange, I got no errors when testing.
-
Emoticons resource stolen from Gothem: https://community.multitheftauto.com/index.php?p= ... 810&vote=5 Original: https://community.multitheftauto.com/index.php?p= ... ls&id=1219 Edit: Car mod: https://community.multitheftauto.com/index.php?p= ... ls&id=2815
-
Try this: function actualizarPosicionSonido( sound, vehicle ) if sound and vehicle then x, y, z = getElementPosition( vehicle ) setElementPosition( sound, x, y, z ) end end function getSoundPath( id ) if id == 1 then return "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX" elseif id == 2 then return "http://194.169.201.177:8085/live3.mp3" elseif id == 3 then return "http://194.169.201.177:8085/liveDial.mp3" elseif id == 4 then return "http://194.169.201.177:8085/liveser.mp3" elseif id == 5 then return "http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u" elseif id == 7 then return "http://streaming.tst.es/stcasx/va90winlive2001/play.asx" end end sound = {} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then x, y, z = getElementPosition( veh ) path = getSoundPath( id ) sound[player] = {} sound[player].theSound = playSound3D( path, x, y, z, false ) sound[player].path = path sound[player].x = x sound[player].y = y sound[player].z = z if volumebar then volume = guiScrollBarGetScrollPosition (volumebar) / 50 else volume = 2.5 end sound[player].volume = volume sound[player].timer = setTimer( actualizarPosicionSonido, 50, 0, sound[player].theSound, getPedOccupiedVehicle( player ) ) setSoundMaxDistance( sound[player], maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ player ] ) killTimer( sound[player].timer ) sound[ player ] = nil setElementData( player, "radio", false ) end end )
-
function onPedClick(button, state, absX, absY, wx, wy, wz, element) if element and getElementType(element) == "ped" and state=="down" then local x, y, z = getElementPosition(getLocalPlayer()) if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then guiSetVisible(myGUIElement, true) end end end addEventHandler("onClientClick", getRootElement(), onPedClick)
-
function pedLoad ( ) createPed ( 230, -694.07299804688, 960.86596679688, 12.245250701904 ) end addEventHandler ( "onResourceStart", resourceRoot, pedLoad ) With your way, you would be creating a ped every time a resource starts.
-
Most of what you said is already achieveable via scripting, if you got some knowledge, you can get most of what you said done.
-
Lo unico que se es que la wiki no es "avanzada" para nadie, si sabes empezar, podes crear cosas simples, no empezando por crear un game mode Roleplay desde 0 o algo por el estilo (los RP suelen ser mas dificiles por eso).
-
For your information, MTA 1.1 has been released already, beta's are over.
-
You welcome.
-
setGameType is a function, it doesn't go in meta.xml, you put that in a .lua script.
-
That's right, but if you use setGameType in a script onResourceStart, it'll be set every time the resource starts.
-
Nice one, keep up the good work!
