Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Ah, no habia leido bien. local teams = { getTeamFromName("Team 1"), getTeamFromName("Team 2"), } addEventHandler("onPlayerLogin",root, function () local team = teams[math.random(#teams)] if (team) then setPlayerTeam(source, team) end end)
  2. local teams = { getTeamFromName("Team 1"), getTeamFromName("Team 2"), } addEventHandler("onPlayerJoin",root, function () local team = teams[math.random(#teams)] if (team) then setPlayerTeam(source, team) end end)
  3. Use: getCursorPosition to compare the position of the rectangle?
  4. Castillo

    Weapon Stats

    Well, I don't know what's wrong then, it works perfectly here.
  5. Castillo

    Weapon Stats

    @Evil-Codr3: What has a login system to do with what Xeno want's? @Xeno: You have set it up as server side, right?
  6. It's a public resource, I don't see why couldn't you use it on your server?
  7. Castillo

    Weapon Stats

    Which one doesn't work? I have tested my last code and it worked perfectly. It doesn't save on logout, it'll save on quit and then load on login.
  8. wndMain = { 'wnd', text = 'BADWOLF FREEROAM', x = 10, y = 170, width = 250, controls = { {'img', id='logo', src='logo.png', width=280, height=5 }, {'br'}, {'btn', id='kill', onclick=killLocalPlayer}, {'btn', id='skin', window=wndSkin}, {'btn', id='anim', window=wndAnim}, --{'btn', id='weapon', window=wndWeapon}, {'btn', id='clothes', window=wndClothes}, --{'btn', id='playergrav', text='grav', window=wndGravity}, {'btn', id='warp', window=wndWarp}, {'btn', id='Teleports', onclick=teleports}, --{'btn', id='stats', window=wndStats}, --{'btn', id='bookmarks', window=wndBookmarks}, {'br'}, {'chk', id='jetpack', onclick=toggleJetPack}, {'chk', id='falloff', text='fall off bike', onclick=toggleFallOffBike}, {'br'}, {'lbl', text='Pos:'}, {'lbl', id='xpos', text='x', width=45}, {'lbl', id='ypos', text='y', width=45}, {'lbl', id='zpos', text='z', width=45}, {'btn', id='setpos', text='map', window=wndSetPos}, {'btn', id='setinterior', text='int', window=wndSetInterior}, {'br'}, {'br'}, {'lbl', text='Vehicles'}, {'br'}, {'lbl', text='Current:'}, {'lbl', id='curvehicle'}, {'br'}, {'btn', id='createvehicle', window=wndCreateVehicle, text='create vehicle'}, {'btn', id='repair', onclick=repairVehicle}, {'btn', id='flip', onclick=flipVehicle}, {'btn', id='upgrades', window=wndUpgrades}, {'btn', id='color', onclick=openColorPicker}, {'btn', id='paintjob', window=wndPaintjob}, {'br'}, {'chk', id='lightson', text='Lights on', onclick=forceLightsOn}, {'chk', id='lightsoff', text='Lights off', onclick=forceLightsOff}, {'br'}, }, oncreate = mainWndShow, onclose = mainWndClose }
  9. Castillo

    Weapon Stats

    Ok, I've found the problem, the account data has a character limit, so the JSON string is not 100% saved. function saveWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local stats = "" for stat=69, 81 do local value = getPedStat(player, stat) stats = stats ..",".. stat ..";".. value end setAccountData(account, "weaponStats", stats) end end function loadWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local statsData = getAccountData(account,"weaponStats") local stats = split(statsData, ",") for k, v in ipairs(stats) do local stat = split(v, ";") setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) end end end addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) This one works.
  10. Maybe because you got almost all the client side in the server side? -- client side: function gunWindow( ) buyGun_Window = guiCreateWindow( 374,104,346,519,"Select Your Weapon",false ) guiWindowSetSizable( buyGun_Window,false ) weaponList_Grid = guiCreateGridList( 11,31,324,435,false,buyGun_Window ) weaponAccept_Button = guiCreateButton( 12,477,118,33,"Accept",false,buyGun_Window ) addEventHandler("onClientGUIClick",weaponAccept_Button,giveMeWeaponHandler,false) weaponCancel_Button = guiCreateButton( 213,477,118,31,"Cancel",false,buyGun_Window ) addEventHandler("onClientGUIClick",weaponAccept_Button, function () guiSetVisible(buyGun_Window,false) showCursor(false,false) end, false) local id = guiGridListAddColumn( weaponList_Grid, "ID", 0.85 ) local price = guiGridListAddColumn( weaponList_Grid, "Price", 0.85 ) local level = guiGridListAddColumn( weaponList_Grid, "Level", 0.85) local wname = guiGridListAddColumn( weaponList_Grid, "Weapon name", 0.85 ) local file = xmlLoadFile ( "weapons.xml" ) if (file) then for _,group in ipairs(xmlNodeGetChildren(file)) do local row = guiGridListAddRow(weaponList_Grid) local name = xmlNodeGetAttribute(group,"name") guiGridListSetItemText(weaponList_Grid,row,1,name,true,false) for _,weapon in ipairs(xmlNodeGetChildren(group)) do local row = guiGridListAddRow(weaponList_Grid) local id = xmlNodeGetAttribute(weapon,"id") local name = xmlNodeGetAttribute(weapon,"name") local price = xmlNodeGetAttribute(weapon,"price") local level = xmlNodeGetAttribute(weapon,"level") guiGridListSetItemText(weaponList_Grid,row,1,id,false,false) guiGridListSetItemText(weaponList_Grid,row,2,price,false,false) guiGridListSetItemText(weaponList_Grid,row,3,level,false,false) guiGridListSetItemText(weaponList_Grid,row,4,name,false,false) end end end showCursor(true, true) setElementData(weaponList_Grid,"expanded","none") xmlUnloadFile ( file ) end addEvent( "hitTheMarker", true ) addEventHandler( "hitTheMarker", root, gunWindow ) function giveMeWeaponHandler(button,state) if (button == "left" and state == "up") then local row,col = guiGridListGetSelectedItem(weaponList_Grid) if (row and col and row ~= -1 and col ~= -1) then local selected = guiGridListGetItemText(weaponList_Grid,row,col) local selected = tonumber(selected) if selected then triggerServerEvent("giveWeaponFromGUI",localPlayer,selected) guiSetVisible(buyGun_Window,false) showCursor(false,false) else outputChatBox("Invalid arguments.") end else outputChatBox("Please select a weapon.") end end end -- server side: function giveMeWeapon(weaponid) if weaponid then giveWeapon(source, weaponid, 500, true) end end addEvent("giveWeaponFromGUI",true) addEventHandler("giveWeaponFromGUI",root,giveMeWeapon)
  11. Castillo

    Rank System

    function setMyRank ( theKiller ) local account = getPlayerAccount(theKiller) if (account and not isGuestAccount(account)) then local money = getPlayerMoney(theKiller) givePlayerMoney( theKiller, 5) setAccountData( account, "theMoney", money) end end addEvent("onZombieWasted",true) addEventHandler ( "onZombieWasted", getRootElement(), setMyRank ) function chatbox(text, msgtype) local name = getPlayerName(source) local money = getPlayerMoney(source) if (msgtype == 0) then if money > 50 then outputChatBox("[Newbie]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [Newbie] " .. name .. ": " .. text) elseif money > 500 then cancelEvent(true) outputChatBox("[Amateur]" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [Amateur] " .. name .. ": " .. text) elseif money > 5000 then cancelEvent(true) outputChatBox("[Pro]" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [Pro] " .. name .. ": " .. text) else outputChatBox("#FFFF00".. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: " .. name .. ": " .. text) end elseif (msgtype == 2) then end end addEventHandler("onPlayerChat", root, chatbox)
  12. Castillo

    help!!

    That's because it only detects players or vehicles. You can use marker's instead, they should detect object's as well.
  13. Can't you use element data to store the experience temporary? P.S: It's dxDrawText Not dxDrawCreateText
  14. An example of what? I already posted that triggerServerEvent doesn't do what Klesh want's, just find another way to do it.
  15. Of course it won't, you have the "pThink" variable in the server side and you want to use it on the client side.
  16. triggerServerEvent will only return if it was success or not, it doesn't work like a function using "return".
  17. You're setting the text to "Random" when a map start's, you're setting a next map AFTER it started?
  18. Castillo

    Weapon Stats

    Try this (Not tested): function saveWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local stats = {} for stat=69, 81 do local value = getPedStat(player, stat) stats[stat] = value end setAccountData(account, "weaponStats", toJSON(stats)) end end function loadWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local statsData = getAccountData(account,"weaponStats") if (statsData and statsData ~= "") then for stat, value in pairs(fromJSON(statsData)) do setPedStat(player, stat, value) end end end end addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) It should save all stats and their values as a JSON string in the account data "weaponStats", then unpack the JSON string and set them.
  19. function setOnFire(attacker, attackerweapon, bodypart, loss) if (attackerweapon == 6) and (loss > 1) then setPedOnFire(source, true) end end addEventHandler ("onClientPlayerDamage", getRootElement(), setOnFire) This is client side only.
  20. You're welcome. I don't know if that function does what you want. It work's like this: setPedAimTarget(myPed, 0, 0, 5) It doesn't set the target to a player or another ped or a vehicle.
  21. Please don't start a fight. @Try: I've just found this function: setPedAimTarget
  22. You mean using the event onClientPlayerDamage?
  23. I don't understand what do you mean, onPlayerDamage is server side only, everyone should be able to see the fire.
×
×
  • Create New...