OnPlayerRequestClass and spawn problem
#1

Hello. I do not even know how to describe this bug, watch the video.
Video: https://www.youtube.com/watch?v=-h4u...ature=*********
Code:
Code:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddStaticVehicle(411, 2977.9031,1295.5956,18.2517,259.4196, 1, 1);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetSpawnInfo(playerid, 0, 0, 2980.9031,1295.5956,18.2517,259.4196, 0, 0, 0, 0, 0, 0);
	SpawnPlayer(playerid);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/tp", cmdtext, true, 3) == 0)
	{
		SetPlayerPos(playerid, 2977.9031,1295.5956,18.2517);
		return 1;
	}
	if (strcmp("/kill", cmdtext, true, 5) == 0)
	{
		SetPlayerHealth(playerid, 0.0);
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
Does anyone know how to fix it?
Reply
#2

At OnPlayerRequestClass you did 2 things:
1- Set player spawn info (make him spawn at some certain place) coords of exactly in front of the car.
2- SpawnPlayer (which will send the player to spawn immediately not giving him a chance to enter class select)
So basically if you don't want him to spawn, remove SpawnPlayer(playerid); if you want to change the spawn info change the parameters of setspawninfo.
Pretty crystal clear if you ask me.
Reply
#3

I want to spawn him in a certain place, so as not to press "SPAWN" button
Reply
#4

Quote:
Originally Posted by FelixAquero
View Post
I want to spawn him in a certain place, so as not to press "SPAWN" button
Then this?
Quote:

if you want to change the spawn info change the parameters of setspawninfo.

change this line
PHP Code:
SetSpawnInfo(playerid002980.9031,1295.5956,18.2517,259.4196000000); 
Reply
#5

Nothing changed, automatic spawn is not avaliable. Problem has not solved
Video: https://*********/NPtr3O8Casg
Code:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddStaticVehicle(411, 2977.9031,1295.5956,18.2517,259.4196, 1, 1);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetSpawnInfo(playerid, 0, 0, 2980.9031,1295.5956,18.2517,259.4196, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/tp", cmdtext, true, 3) == 0)
	{
		SetPlayerPos(playerid, 2977.9031,1295.5956,18.2517);
		return 1;
	}
	if (strcmp("/kill", cmdtext, true, 5) == 0)
	{
		SetPlayerHealth(playerid, 0.0);
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
Reply
#6

what the fuck... that's NOT what i said...

put back SpawnPlayer and change the parameters of SetSpawnInfo!
Reply
#7

Where do I need to insert SetSpawnInfo?
Reply
#8

I think you do not understand what the bug is. On both videos, I show that the player visually spawned, but on the server side he is stay in the car. I want to fix this
Reply
#9

Why have you posted a second thread regarding the same problem?...


Reset the camera on the player spawn.

Code:
SetCameraBehindPlayer(playerid);
Reply
#10

I thought I solved the problem, but it was not so. Your method also does not help
Reply
#11

Quote:
Originally Posted by FelixAquero
View Post
How to make a player spawn after death? Because, as it is now, it should not be so.
Because you aren't getting the same situation, I'm thinking you've got other issues.
Reply
#12

Yes, it works, but the player does not spawn automatically.
Reply
#13

That's why I'm saying about whether you've got anything else that's on there that's causing the discrepancy.
Reply
#14

I do not use filterscripts, I do not know what's the matter. I kind of solved the problem this way:
Code:
SetTimerEx("timer", 1, 0, "i", playerid);
...

forward timer(playerid);
public timer(playerid) {
	SpawnPlayer(playerid);
	return true;
}
I do not know if this is the right decision, but it works. In any case, thanks for your attention.
Reply
#15

That's bad, as if you use my script that I handed you, and simply change this

PHP Code:
public OnPlayerRequestClass(playeridclassid)
{
    
SendClientMessage(playerid, -1"OnPlayerRequestClass Called");
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    
SetSpawnInfo(playerid001958.37831343.157215.3746280000000);
    
SpawnPlayer(playerid);
    return 
1;

it works fine... It only bugs out when I use /spawn, and that's likely because of what you've ripped out of the OnPlayerRequestSpawn.

Change it to this
PHP Code:
public OnPlayerRequestClass(playeridclassid)
{
    
SendClientMessage(playerid, -1"OnPlayerRequestClass Called");
    
//SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    //SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    //SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    
SetSpawnInfo(playerid001958.37831343.157215.3746280000000);
    
SpawnPlayer(playerid);
    return 
1;

and viola, your bug replicates.

Don't rip out things without considering that they'll cause issues later.
Reply
#16

It really works! Thank you very much.
Reply
#17

No worries, to a point it was interesting to try mess about with it.

Glad to see we got to the bottom of it.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)