IStarkI Posted September 11, 2018 Share Posted September 11, 2018 I have a problem with this code and I need some help. So when I am changing the weapon to AK47 the only thing I receive is spam on chat and I have no idea how to fix it. It's only happening when I add engineImportTXD and engineReplaceModel. Without It everything works perfectly. Can someone help me or give me some better ideas? GM - DayZ function wczytaj() txd = engineLoadTXD ( "models/ak47.txd" ) dff = engineLoadDFF ( "models/ak47.dff" ) outputChatBox ( "wczytano podmianki" ) end addEventHandler( "onClientResourceStart", getRootElement(), wczytaj ) function podmiankibronki () local bronka = getPlayerWeapon ( localPlayer ) if(getElementData(localPlayer,"currentweapon_1") == "AK47" and bronka == 31) then engineImportTXD ( txd, 356 ) engineReplaceModel ( dff, 356 ) outputChatBox ( "wczytano ak47" ) end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, podmiankibronki ) Link to comment
Dimos7 Posted September 12, 2018 Share Posted September 12, 2018 (edited) function wczytaj() txd = engineLoadTXD ( "models/ak47.txd" ) dff = engineLoadDFF ( "models/ak47.dff" ) outputChatBox ( "wczytano podmianki" ) end addEventHandler( "onClientResourceStart", getRootElement(), wczytaj ) function podmiankibronki () local bronka = getPlayerWeapon ( localPlayer ) if(getElementData(localPlayer,"currentweapon_1") == "AK47" and bronka == 30) then engineImportTXD ( txd, 355 ) engineReplaceModel ( dff, 355) outputChatBox ( "wczytano ak47" ) end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, podmiankibronki ) Edited September 12, 2018 by Dimos7 Link to comment
JeViCo Posted September 12, 2018 Share Posted September 12, 2018 function wczytaj() txd = engineLoadTXD ( "models/ak47.txd" ) dff = engineLoadDFF ( "models/ak47.dff" ) --outputChatBox ( "wczytano podmianki" ) end addEventHandler( "onClientResourceStart", resourceRoot, wczytaj ) function podmiankibronki () local bronka = getPlayerWeapon ( localPlayer ) if(getElementData(localPlayer,"currentweapon_1") == "AK47" and bronka == 31) then engineImportTXD ( txd, 356 ) engineReplaceModel ( dff, 356 ) outputChatBox ( "wczytano ak47" ) end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, podmiankibronki ) @IStarkI Link to comment
IStarkI Posted September 12, 2018 Author Share Posted September 12, 2018 @Dimos7 Model ID is 356. @JeViCo The model is replacing correctly but it keep spamming on chat "Wczytano AK47" like the script is repeating over and over. When I leave the script like function podmiankibronki () local bronka = getPlayerWeapon ( localPlayer ) if(getElementData(localPlayer,"currentweapon_1") == "AK47" and bronka == 31) then --engineImportTXD ( txd, 356 ) --engineReplaceModel ( dff, 356 ) outputChatBox ( "wczytano ak47" ) end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, podmiankibronki ) everything works fine. I really have no idea whats wrong with this and its possible that there is another script that is bugging it? Link to comment
Dimos7 Posted September 12, 2018 Share Posted September 12, 2018 afk model id iss 355 https://wiki.multitheftauto.com/wiki/Weapons check it and id is 30 not 31 31 and 356 is for m4 Link to comment
JeViCo Posted September 12, 2018 Share Posted September 12, 2018 (edited) @IStarkI every time you switch the any weapon, model will be replaced again and again + message in chat will appear too removed elementData function podmiankibronki (_, slot) local bronka = getPlayerWeapon ( localPlayer ) if slot == 5 and getPedWeapon(localPlayer) == 31 then -- 5 - rifle slot, 31 - m4 id (you said your weapon id is 356 and this is an M4 engineImportTXD ( txd, 356 ) engineReplaceModel ( dff, 356 ) --outputChatBox ( "wczytano ak47" ) end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, podmiankibronki ) Are you trying to make several models per weapon or what? Edited September 12, 2018 by JeViCo Link to comment
IStarkI Posted September 12, 2018 Author Share Posted September 12, 2018 (edited) @Dimos7 @JeViCo Im trying to replace several models to m4 (ID: 31 Model: 356) so ak47 is only a name (Like I said DayZ GM so I have many weapons). The problem is that when I switch the weapon to AK47 I receive a massive spam on chat (Many messages per second), the outputChatBox is only my way to test if it works. The way with the slot can work, so I'll try it when I get home and then let you know what happened. Edit: And the weapon isnt replacing. Only when i change to another weapon (for example ACR) I see the ak replace (and thats obvious because theres only AK instruction). Edited September 12, 2018 by IStarkI Link to comment
Dimos7 Posted September 12, 2018 Share Posted September 12, 2018 (edited) fuction replaceWeapon() txd = engineLoadTXD("models/ak47.txd") dff = engineLoadDFF("models/ak47.dff") engineImportTXD(txd, 356) engineReplaceModel(dff, 356) end addEventHandler("onClientResourceStart", resourceRoot, replaceWeapon) Edited September 12, 2018 by Dimos7 Link to comment
IStarkI Posted September 12, 2018 Author Share Posted September 12, 2018 @JeViCo The way with the slot didnt work. Here's what's going on - video. Honestly im out of ideas. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now