Page 1 of 1

[BUG] Bug with first spawn

Posted: March 1st, 2019, 11:19 am
by rww
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.

Re: [BUG] Bug with first spawn

Posted: March 1st, 2019, 1:37 pm
by Armelin
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.

Re: [BUG] Bug with first spawn

Posted: March 2nd, 2019, 5:00 am
by rww
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.