[BUG] Bug with first spawn

Need advices or help troubleshooting? Ask for help here.
Post Reply
rww
Posts: 16
Joined: June 15th, 2018, 1:49 am

[BUG] Bug with first spawn

Post by rww » March 1st, 2019, 11:19 am

Description:
First spawn - event 'onPlayerSpawn' doesn't work and not all functions works on 'onPlayerCredential' event.

Reproducible:
Always

What you were doing when the bug happened:
With onPlayerSpawn:

Code: Select all

function onPlayerSpawned(playerid)
	setPlayerCash(playerid, 0)
	setPlayeHealth(playerid, 150)
	givePlayerWeapon(playerid, 15, 600)
end
registerEvent("onPlayerSpawned", "onPlayerSpawn")
And after join, I have $500, 200hp and don't have a weapon.

With 'onPlayerCredential'

Code: Select all

function onPlayerJoin(playerid)
	print("[JOIN] [" .. playerid .. "] [ " .. getPlayerName(playerid) .. " ] IP: [ " .. getPlayerIp(playerid) .. " ]")

	local sId = math.random(1, #spawnInfo)
	spawnPlayer(playerid, spawnInfo[sId][1], spawnInfo[sId][2], spawnInfo[sId][3])
	setPlayerSkin(playerid, spawnInfo[sId][4])
	setPlayerColor(playerid, spawnInfo[sId][5])
	setPlayerCash(playerid, 0)
	setPlayeHealth(playerid, 150)
	givePlayerWeapon(playerid, 15, 600)
end
registerEvent("onPlayerJoin", "onPlayerCredential")
Like above, but skin, color and spawn position works.
Image

Armelin

Re: [BUG] Bug with first spawn

Post by Armelin » March 1st, 2019, 1:37 pm

onPlayerSpawn
This function is triggered when the player respawns after dying
As for the other issue try to give the weapon and health before changing the skin or make use of a timer.

rww
Posts: 16
Joined: June 15th, 2018, 1:49 am

Re: [BUG] Bug with first spawn

Post by rww » March 2nd, 2019, 5:00 am

Okey, I try

Code: Select all

	setPlayerCash(playerid, 0)
	setPlayeHealth(playerid, 150)
	givePlayerWeapon(playerid, 10, 300)
	givePlayerWeapon(playerid, 12, 600)
	givePlayerWeapon(playerid, 14, 300)
	setPlayerSkin(playerid, spawnInfo[sId][4])
	setPlayerColor(playerid, spawnInfo[sId][5])
and I still have $500 and full hp (200, not 150), weapons also I don't have. (This about onPlayerCredential)

Image

With timer I test yesterday, sometimes don't work (with 2000ms) :/

That why, I preffer, that onPlayerSpawn works also with first spawn, after game check, that player is spawned.
Image

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 13 guests