Jump to content
  • 0

Players have no weapons for other players


Yazir

Question

Hello!

I have a problem that i couldn't solve for the past month. I am making a gamemode. On start of the round i spawn players in different dimension in air, with parachutes (given by giveWeapon). They can pick up weapons and walk around the map, but sometimes player don't see other player's (player2) weapon and even if the player2 is shooting at him, he doesn't deal any damage.

What could be the issue? Please help me. I have tried many various things like manually giving weapon to a player, setting his weapon and sending a message to players to update player2 but with no result. Tried moving/spawning into other dimension in one place then moving them in air. Or the same but spawning far away (thought it could be some streaming issue). No results.

Setting giveWeapon's set as current to false seemed like it kinda made the issue happen less often.

Weapons that are given when the player is nearby are visible.

Link to comment

24 answers to this question

Recommended Posts

  • 0

It seems random, sometimes it is every match, sometimes it's not happening.

The gamemode and resource is written by myself, but i can provide you scripts where i spawn player etc.

for key,player in ipairs(lobby["players"]) do
	local skin = getElementData( player, "skin" )
	addStat(player,"played",1)
	spawnPlayer( player, -1500*key,-1500*key,1500*key, nil, skin, nil, dim)
	setElementDimension( player, dim )
	setElementPosition( player, 1000*key, 1000*key, 1000*key )
	setTimer(
	function()
		setElementData( player, "canFire", true )
		giveWeapon( player, 46, 1, true)
		setElementDimension( player, dim )
		setElementPosition( player, math.random(-700,700)+x, math.random(-500,500)+y, 800, true )
		setElementVelocity( player, math.random(-30,30), math.random(-30,30), 50 )
		setElementData( player, "headshotMulti", 2 )
		setElementData( player, "score", -1 )
	end,2000,1)
end

Player spawning. Tried delaying changing dimension/spawning and spawning players far apart.

if itemdata[3] == "equip" then
	giveWeapon( source, itemdata[4], itemdata[5], true)
	removePlayerItem(source, iid, item)
end

Code for giving weapon when player equips them. Players can equip item any time they want (single time). Setting set current weapon to false seemed to help, made it happen less often but that might have been just random.

 

It was a problem for this gamemode for since i remember. Also when player shoots and you don't see his weapon, he occasionally swings his fist and when he's moving it looks like he is running in a direction and gets warped back to the position he was standing originally every position update.

@ccw

Edited by Yazir
Link to comment
  • 0

I have found this post with I think similar issue: 

Though there's no solution as the author just closes the  topic.

 

On the other hand I wanted to make something like this

addEventHandler( "onPlayerWeaponFire", root,
function ( wep, eX, eY, eZ, hitE, sX, sY, sZ )
	local amm = getPedTotalAmmo( source )
	local clip = getPedAmmoInClip( source )
	outputChatBox( tostring( amm ) )
	takeWeapon( source, wep, amm )
	giveWeapon( source, wep, amm-1, true )
end ) 

But as i have made this, I've seen that there is no function to get and set player's ammo in clip serverside.

Link to comment
  • 0
  • MTA Team

Try this and see what gets output in the server log:

Client:

function sendinfo()
    local slotinfo = {}
    for i,player in ipairs(getElementsByType("player")) do
        slotinfo[player] = getPedWeaponSlot(player)
    end
    triggerServerEvent("onSlotInfo", resourceRoot, slotinfo)
end
setTimer(sendinfo,1000,0)

 

Server:

addEvent( "onSlotInfo", true )
addEventHandler( "onSlotInfo", resourceRoot,
    function ( slotinfo )
        for _,player in ipairs(getElementsByType("player")) do
            local slotServer = getPedWeaponSlot(player)
            local slotClient = slotinfo[player]
            if slotServer ~= slotClient then
                setPedWeaponSlot( player, 0 )
                setPedWeaponSlot( player, slotServer )
                outputDebugString( "onSlotInfo"
                            .. " client:" .. tostring(getPlayerName(client))
                            .. " player:" .. tostring(getPlayerName(player))
                            .. " slotServer:" .. tostring(slotServer)
                            .. " slotClient:" .. tostring(slotClient)
                                )
            end
        end
    end
)

 

Link to comment
  • 0

@ccw

[2017-03-22 16:01:11] INFO: onSlotInfo client:Yazir player:manson slotServer:11 slotClient:0
[2017-03-22 16:01:11] INFO: onSlotInfo client:manson player:Yazir slotServer:11 slotClient:0
[2017-03-22 16:01:29] INFO: onSlotInfo client:manson player:Yazir slotServer:0 slotClient:11
[2017-03-22 16:02:42] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:02:48] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0  [DUP x3]
[2017-03-22 16:02:49] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:03:09] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:03:10] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:03:16] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0  [DUP x3]
[2017-03-22 16:03:17] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:03:19] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:03:25] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:03:31] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:03:37] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0  [DUP x3]
[2017-03-22 16:03:46] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:03:52] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:03:52] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:03:58] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:03:58] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:04:11] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:04:46] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:04:48] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:04:54] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0  [DUP x2]
[2017-03-22 16:05:13] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:05:14] INFO: onSlotInfo client:Yazir player:manson slotServer:3 slotClient:0
[2017-03-22 16:05:16] INFO: onSlotInfo client:Yazir player:manson slotServer:3 slotClient:0  [DUP x2]
[2017-03-22 16:05:16] INFO: onSlotInfo client:manson player:manson slotServer:3 slotClient:2
[2017-03-22 16:05:17] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:05:23] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0  [DUP x3]
[2017-03-22 16:05:23] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:05:25] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:05:25] INFO: onSlotInfo client:Yazir player:manson slotServer:12 slotClient:2
[2017-03-22 16:05:26] INFO: onSlotInfo client:Yazir player:manson slotServer:5 slotClient:0
[2017-03-22 16:05:27] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:05:33] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0  [DUP x3]
[2017-03-22 16:05:33] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:05:55] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:05:56] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:05:59] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0  [DUP x2]
[2017-03-22 16:05:59] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:05:59] INFO: onSlotInfo client:Yazir player:manson slotServer:3 slotClient:0
[2017-03-22 16:06:00] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:00] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:06:01] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:07] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:06:07] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:06:07] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:07] INFO: onSlotInfo client:Yazir player:manson slotServer:8 slotClient:0
[2017-03-22 16:06:08] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:08] INFO: onSlotInfo client:manson player:manson slotServer:6 slotClient:5
[2017-03-22 16:06:08] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:06:09] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:09] INFO: onSlotInfo client:Yazir player:manson slotServer:8 slotClient:0
[2017-03-22 16:06:10] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:10] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:06:11] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:11] INFO: onSlotInfo client:Yazir player:manson slotServer:5 slotClient:0
[2017-03-22 16:06:17] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:06:17] INFO: onSlotInfo client:Yazir player:manson slotServer:5 slotClient:0  [DUP x5]
[2017-03-22 16:06:17] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:17] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:06:18] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:18] INFO: onSlotInfo client:Yazir player:manson slotServer:3 slotClient:0
[2017-03-22 16:06:19] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:19] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:06:24] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x4]
[2017-03-22 16:06:24] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0  [DUP x4]
[2017-03-22 16:06:24] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:24] INFO: onSlotInfo client:Yazir player:manson slotServer:6 slotClient:0
[2017-03-22 16:06:25] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:25] INFO: onSlotInfo client:Yazir player:manson slotServer:4 slotClient:0
[2017-03-22 16:06:27] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:27] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:28] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:28] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:06:29] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:35] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0  [DUP x5]
[2017-03-22 16:06:35] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0  [DUP x5]
[2017-03-22 16:06:35] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:06:35] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:39] INFO: onSlotInfo client:manson player:Yazir slotServer:4 slotClient:0
[2017-03-22 16:06:39] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0
[2017-03-22 16:06:45] INFO: onSlotInfo client:Yazir player:manson slotServer:2 slotClient:0  [DUP x3]

Though weapons were visible that round

Link to comment
  • 0

I have made another test because previous wasn't made by me.  They've told me they both didn't see their weapons

 

There's a new test with the bug after a few tries (with your code)

http://cdn.pasteraw.com/c5zr12qtyge4ssv0hfk1n2y2yaphgi0

The issues were: Pogromca_ didn't have a weapon for me ( i didn't see his shotgun) and when he tried to shoot, it wouldn't let him (after pressing lpm nothing happened).

Next round I've got the issue myself and it happened with mac-10 in middle of shooting. I couldn't shoot anymore resulting in my death.

Pogromca_ now has weird issue that if he starts running while he is aiming, the weapon will get changed. Didn't experience that myself and maybe it's affected cause of  your script.

@ccw

edit: I couldn't shoot because i had 0 ammo. I have also made custom weapons with setWeaponProperty. Maybe that might help.

 

Link to comment
  • 0
  • MTA Team

Make a client script which displays all the weapons and ammo of the remote players.
e.g.

for i,plr in ipairs(getElementsByType("player")) do
    for slot=0,12 do
        weap = getPedWeapon(plr,slot)
        ammo = getPedAmmoInClip(plr,slot)
        dxDrawText( plrname .. weap ..ammo ..

 

Link to comment
  • 0

It was hard to work with them but I've got some screenshots

function renderDebug(  )
	for i,plr in ipairs(getElementsByType("player")) do
		if not isElement( plr ) then return end
	    for slot=0,12 do
	        weap = getPedWeapon(plr,slot)
	        ammo = getPedAmmoInClip(plr,slot)
	        ammoTot = getPedTotalAmmo( plr, slot )
	        dxDrawText( slot .. " " .. getPlayerName( plr ) .. " (D".. getElementDimension( plr ) .. ") " .. tostring(weap) .. " " .. tostring(ammo) .. "/" .. tostring(ammoTot), 230 + i * 180, slot*15, tocolor( 255, 255, 255, 150 ), 0.5 )
	    end
	end
end

local isWpnDebug = false
addCommandHandler( "wpndebug", 
function ( )
	if not isWpnDebug then addEventHandler( "onClientRender", root, renderDebug ) isWpnDebug = true outputChatBox( "ON" )
	else removeEventHandler( "onClientRender", root, renderDebug ) isWpnDebug = false end
end )

Code of that display

 

And I'm really sorry because I've just seen this topic is in Windows, not Linux thread. The server is on linux.

 

From my observations it seems that players that are not streamed in and player equips them and sets as their weapon, are invisible later ( I've used giveWeapon setWeaponCurrent=true to make the bug happen more frequently).

There was one little bug that one guy seen I have shotgun, but in reality i had chainsaw. I "shot" it once and it got fixed. It was one of the first screens. On the last screens me (harley quinn model) have no weapon in demonek's ss.

Edited by Yazir
Link to comment
  • 0

Tested on 2 clients and it doesn't work.

 

Note: Weapons given when player is nearby other player are visible (except when the weapon is already invisible, but I'm not sure about this one).

Edited by Yazir
Link to comment
  • 0

It seems to be working. After 4 games with 2 players (new client(me) + old client)  I have seen every weapon and the old one didn't see my weapons atleast twice.

Then 3 games both with new clients it worked perfectly till one moment. Other player didn't see most of my weapons (he saw only one, tec-9) but when i threw satchel at him, all my weapons were visible after that.

 

I suggest pushing this update already because it works nearly perfectly.

Thanks.

Link to comment
  • 0

Sorry, I didn't check the forums for couple days. I thought the update has been pushed and it works fine on my server now as I or my players experience the issue. There was only one occurence but that was when player still had outdated client.

I will test it soon.

 

 

There's however another issue not related to this problem:

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...