NopadaN

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About NopadaN

  • Rank
    Vic

Details

  • Gang
    Fart
  • Location
    Kökény
  • Occupation
    Fart
  • Interests
    RolePlay, MMO
  1. Okay, I wanted just this type of answer. Now I'll try the whole thing you answered. Thank you, all of your help!
  2. I tried with my friends, and still doesn't work. (I corrected the database name) function onCharacterLogOut(player) -- just an example --normal code goes first, that you already should have EDIT: <--- What do you mean with this? Should I have put the existing script here? local uzi_stat = getPedStat(player, 75) local mp5_stat = getPedStat(player, 76) local query = mysql:query_free("UPDATE `characters` SET `uzi_skill`=" .. mysql:escape_string(uzi_stat) .. ", `mp5_skill`=" .. mysql:escape_string(mp5_stat) .. " WHERE id=" .. mysql:escape_string(getElementData(player, "dbid"))) if not query then outputDebugString("Failed saving weapon stats for " .. getPlayerName(player), 2) end You gave me this script, I'm sure it will work, but I want this to update as I shoot my friend. function uzi ( attacker, attackerweapon, bodypart, loss ) local statz = getPedStat(attacker, 75) local healthh = getElementHealth(source) local setstat = statz + (100.0 - healthh) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 28 or attackerweapon == 32) and (statz < 999) then setPedStat(attacker, 75, setstat) end if (statz > 980) then setPedStat(attacker, 75, 998) end end addEventHandler("onPlayerDamage", getRootElement(), uzi) You've seen the line, I removed the wrong mysql line. Where should I put your script? Because there are plenty of space and room that makes me lost. -------------------------------------- UZI ----------------------------------------------------------- function uzi ( attacker, attackerweapon, bodypart, loss ) local statz = getPedStat(attacker, 75) local healthh = getElementHealth(source) local setstat = statz + (100.0 - healthh) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) --exports['skill']:changeProtectedElementDataEx(source, "ui_skill", tonumber(adminlevel)) <--- I tried with this. Complete FAIL if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 28 or attackerweapon == 32) and (statz < 999) then setPedStat(attacker, 75, setstat) end if (statz > 980) then setPedStat(attacker, 75, 998) end end addEventHandler("onPlayerDamage", getRootElement(), uzi) --------------------------------- M4 ------------------------------------------------------------------- function m4 ( attacker, attackerweapon, bodypart, loss ) local statz2 = getPedStat(attacker, 78) local healthh2 = getElementHealth(source) local setstat2 = statz2 + (100.0 - healthh2) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 31) and (statz2 < 999) then setPedStat(attacker, 78, setstat2) end if (statz > 980) then setPedStat(attacker, 78, 999) end end addEventHandler("onPlayerDamage", getRootElement(), m4) ------------------------------- AK-47 ------------------------------------------------------------------ function ak ( attacker, attackerweapon, bodypart, loss ) local statz3 = getPedStat(attacker, 77) local healthh3 = getElementHealth(source) local setstat3 = statz3 + (100.0 - healthh3) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 30) and (statz3 < 999) then setPedStat(attacker, 77, setstat3) end if (statz > 980) then setPedStat(attacker, 77, 999) end end addEventHandler("onPlayerDamage", getRootElement(), ak) ----------------------------------- SPAZ SHOTGUN -------------------------------------------------------- function spaz ( attacker, attackerweapon, bodypart, loss ) local statz4 = getPedStat(attacker, 74) local healthh4 = getElementHealth(source) local setstat4 = statz4 + (100.0 - healthh4) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 27) and (statz4 < 999) then setPedStat(attacker, 74, setstat4) end if (statz > 980) then setPedStat(attacker, 74, 999) end end addEventHandler("onPlayerDamage", getRootElement(), spaz) ------------------------------------ sawed-off ---------------------------------------------------------- function sawed ( attacker, attackerweapon, bodypart, loss ) local statz5 = getPedStat(attacker, 73) local healthh5 = getElementHealth(source) local setstat5 = statz5 + (100.0 - healthh5) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 26) and (statz5 < 999) then setPedStat(attacker, 73, setstat5) end if (statz > 980) then setPedStat(attacker, 73, 999) end end addEventHandler("onPlayerDamage", getRootElement(), sawed) --------------------------------------- MP5 --------------------------------------------------------------- function mp5 ( attacker, attackerweapon, bodypart, loss ) local statz6 = getPedStat(attacker, 76) local healthh6 = getElementHealth(source) local setstat6 = statz6 + (100.0 - healthh6) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 29) and (statz6 < 999) then setPedStat(attacker, 76, setstat6) end if (statz > 980) then setPedStat(attacker, 76, 999) end end addEventHandler("onPlayerDamage", getRootElement(), mp5) -------------------------------------- Sniper -------------------------------------------------------------- function sniper ( attacker, attackerweapon, bodypart, loss ) local statz7 = getPedStat(attacker, 79) local healthh7 = getElementHealth(source) local setstat7 = statz7 + (100.0 - healthh7) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 34 or attackerweapon == 33) and (statz7 < 999) then setPedStat(attacker, 79, setstat7) end if (statz > 980) then setPedStat(attacker, 79, 999) end end addEventHandler("onPlayerDamage", getRootElement(), sniper) --------------------------------------- DEAGLE --------------------------------------------------------------- function deagle ( attacker, attackerweapon, bodypart, loss ) local statz8 = getPedStat(attacker, 71) local healthh8 = getElementHealth(source) local setstat8 = statz8 + (100.0 - healthh8) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 24) and (statz8 < 999) then setPedStat(attacker, 71, setstat8) end if (statz > 980) then setPedStat(attacker, 71, 999) end end addEventHandler("onPlayerDamage", getRootElement(), deagle) -------------------------------------------- PISTOL -------------------------------------------------------------- function pistol ( attacker, attackerweapon, bodypart, loss ) local statz9 = getPedStat(attacker, 69) local healthh9 = getElementHealth(source) local setstat9 = statz9 + (100.0 - healthh9) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 22) and (statz9 < 999) then setPedStat(attacker, 69, setstat9) end if (statz > 980) then setPedStat(attacker, 69, 999) end end addEventHandler("onPlayerDamage", getRootElement(), pistol) function onCharacterLogOut(player) -- just an example --normal code goes first, that you already should have local uzi_stat = getPedStat(player, 75) local mp5_stat = getPedStat(player, 76) local query = mysql:query_free("UPDATE `characters` SET `uzi_skill`=" .. mysql:escape_string(uzi_stat) .. ", `mp5_skill`=" .. mysql:escape_string(mp5_stat) .. " WHERE id=" .. mysql:escape_string(getElementData(player, "dbid"))) if not query then outputDebugString("Failed saving weapon stats for " .. getPlayerName(player), 2) end end end This is the whole script. I'm new in all of this. I understand C programming language, and that knowledge helps a bit, but I'm lost. Hale I don't need the whole script, just an advice. You give me an example, please insert your example to one of the weapons functions ( I'd prefer UZI, because I didn't make m4, ak sql tables yet)
  3. 3laa33 Debug doesn't show anything wrong, just doesn't work at all. Hale I'll try your suggestion today in my hobby server and reply if anything goes well or even wrong. (I need a friend who must log in and kill and repeat the process until I see the mysql table variable change)
  4. Hello everyone! I am beginner in all of this. I am a hobby scripter, because I have interest in scripting. BUT I have problem. I want to make a skill system(like you shoot a leg you get 1points for that), and I found a free resource that varies your skill up to 999 in server side and I found another one that do this client side.(also I won't use it like my scripts in a server) OK I have problems with client AND server side too. I can't connect and update the variable. I created a table for the UZI skill (uzi_skill) to try it, but I can't get working. Original source: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11129 This is just the Uzi skill section. The skill is tied to the character-system. (db: character-system -> table: uzi_skill [tinyint(4)] ) function uzi ( attacker, attackerweapon, bodypart, loss ) local statz = getPedStat(attacker, 75) local healthh = getElementHealth(source) local setstat = statz + (100.0 - healthh) * 0.05 local cteam = getPlayerTeam(attacker) local pteam = getPlayerTeam(source) --exports['skill']:changeProtectedElementDataEx(source, "uzi_skill", tonumber(setstat)) <--- I tried with this. Complete FAIL(I know why) if getTeamName(cteam) == getTeamName(pteam) then return false elseif attacker and getElementType(attacker) == "player" and (attackerweapon == 28 or attackerweapon == 32) and (statz < 999) then setPedStat(attacker, 75, setstat) end if (statz > 980) then setPedStat(attacker, 75, 999) end end addEventHandler("onPlayerDamage", getRootElement(), uzi) I want a bit help, just one example how to do this with this. (Please don't ask in fragments. Also I don't know where to put that script fragment). I'd be happy if someone could help me