[BUG] Bug with first spawn

Need advices or help troubleshooting? Ask for help here.
Post Reply
rww
Posts: 16
Joined: Fri Jun 15, 2018 6:49 am

[BUG] Bug with first spawn

Post by rww » Fri Mar 01, 2019 5:19 pm

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
Posts: 30
Joined: Sun Jul 30, 2017 4:28 am

Re: [BUG] Bug with first spawn

Post by Armelin » Fri Mar 01, 2019 7: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: Fri Jun 15, 2018 6:49 am

Re: [BUG] Bug with first spawn

Post by rww » Sat Mar 02, 2019 11: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: No registered users and 1 guest