TogglePlayerSpectate call OnPlayerClassRequest -
Patchwerk - 06.01.2015
Hi, i have specific problem with TogglePlayerSpectate
When i turn off spectate (TogglePlayerSpectate(playerd, false)) this fuction call OnPlayerSpawn (wiki) BUT in my gamemode it call OnPlayerRequestClass with classid -1 !
Log "OnPlayerRequestClass(PatchwerkQWER,-1)" (after TogglePlayerSpectate)
I use y_hooks but i have just 2 "hook OnPlayerSpawn" and just one "hook OnPlayerRequestClass"
Cheers
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Sid_Alexander - 06.01.2015
Quote:
Originally Posted by Patchwerk
Hi, i have specific problem with TogglePlayerSpectate
When i turn off spectate (TogglePlayerSpectate(playerd, false)) this fuction call OnPlayerSpawn (wiki) BUT in my gamemode it call OnPlayerRequestClass with classid -1 !
Log "OnPlayerRequestClass(PatchwerkQWER,-1)" (after TogglePlayerSpectate)
I use y_hooks but i have just 2 "hook OnPlayerSpawn" and just one "hook OnPlayerRequestClass"
Cheers
|
Try SpawnPlayer(playerid); when you set the spectate to false.
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Patchwerk - 06.01.2015
I did it, but i was bugged in class selection (any buttons)
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Sid_Alexander - 06.01.2015
Quote:
Originally Posted by Patchwerk
I did it, but i was bugged in class selection (any buttons)
|
You can avoid the class selection from your server, Simply add this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
SpawnPlayer(playerid);
return 1;
}
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Patchwerk - 06.01.2015
But i can turn on selection, becouse player is selecting team
But here is still question, why TogglePlayerSpectate call OnPlayerRequestClass? It must call OnPlayerSpawn but not.
EDIT: In new.pwn turn off spectate call OnPlayerSpawn ^.^ any tips?
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Sid_Alexander - 06.01.2015
Quote:
Originally Posted by Patchwerk
But i can turn on selection, becouse player is selecting team
Код:
hook OnPlayerRequestClass(playerid, classid){
if(IsPlayerNPC(playerid)) return 1;
SCMTA(-1,"OnPlayerRequestClass(%p,%d)",playerid,classid);
Debug(DBG_CORE, "Player/Team.pwn", "OnPlayerRequestClass(%p,%d)",playerid,classid);
if(classid == -1){
SpawnPlayer(playerid); // doesn't work,
return 1;
}
SetPlayerPos(playerid, 256.7486,1835.2441,4.7109);
SetPlayerFacingAngle(playerid,90);
ApplyAnimation(playerid,"ON_LOOKERS","wave_loop", 4.0, 0, 0, 0, 0, 0,1);
SetPlayerCameraPos(playerid, 251.4871,1835.7344,4.7109);
SetPlayerCameraLookAt(playerid, 256.7486,1835.2441,4.7109);
SetPVarInt(playerid, "Classid", classid);
printf("classid = %d",classid);
if (classid >= ArmyClass[0] && classid <= ArmyClass[1]){
GameTextForPlayer(playerid, GetMessage(playerid,"ARMADA_CLASS"), 2000, 3);
}
else if (classid >= GuardOutClass[0] && classid <= GuardOutClass[2]){
GameTextForPlayer(playerid, GetMessage(playerid,"DOZORCA_VONKAJSI_CLASS"), 2000, 3);
}
else if (classid >= GuardInClass[0] && classid <= GuardInClass[4]){
GameTextForPlayer(playerid, GetMessage(playerid,"DOZORCA_VNUTORNY_CLASS"), 2000, 3);
}
else if (classid >= MedicClass[0] && classid <= MedicClass[1]){
GameTextForPlayer(playerid, GetMessage(playerid,"LEKAR_CLASS"), 2000, 3);
}else if(classid >= AdminClass[0] && classid <= AdminClass[1]){
GameTextForPlayer(playerid, GetMessage(playerid,"ADMIN_CLASS"), 2000, 3);
}else{
GameTextForPlayer(playerid, GetMessage(playerid,"VEZEN_CLASS"), 2000, 3);
}
return 1;
}
But here is still question, why TogglePlayerSpectate call OnPlayerRequestClass? It must call OnPlayerSpawn but not.
|
It's by default i suppose.
Are you applying TogglePlayerSpectate while registration or something or on a command like /spectate?
If it's under a command i can help.
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Rufio - 06.01.2015
Quote:
Originally Posted by Sid_Alexander
You can avoid the class selection from your server, Simply add this:
pawn Код:
public OnPlayerRequestClass(playerid, classid) { SpawnPlayer(playerid); return 1; }
|
You do realise that would cause the server to skip class selection aswell, right? And if it is not a RP server, that'd make the gamemode look just real bad.
Try this code after you toggle spectating mode off;
pawn Код:
SetSpawnInfo(playerid,team,skin,x,y,z,angle,weap 1, weap 1 ammo, weap 2, weap 2 ammo, weap 3, weap 3 ammo); // Remember that you could always save positions, weapons team and such things via SetPVarInt
SpawnPlayer(playerid);
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Sid_Alexander - 06.01.2015
Quote:
Originally Posted by Rufio
You do realise that would cause the server to skip class selection aswell, right? And if it is not a RP server, that'd make the gamemode look just real bad.
|
Yes, But the explanation on the topic was not enough and i thought it was rp.
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Patchwerk - 06.01.2015
Quote:
Originally Posted by Rufio
You do realise that would cause the server to skip class selection aswell, right? And if it is not a RP server, that'd make the gamemode look just real bad.
Try this code after you toggle spectating mode off;
pawn Код:
SetSpawnInfo(playerid,team,skin,x,y,z,angle,weap 1, weap 1 ammo, weap 2, weap 2 ammo, weap 3, weap 3 ammo); // Remember that you could always save positions, weapons team and such things via SetPVarInt SpawnPlayer(playerid);
|
Thanks, this probably works. I test SetSpawnInfo but before toggle spectating
Re: TogglePlayerSpectate call OnPlayerClassRequest -
Rufio - 06.01.2015
Quote:
Originally Posted by Patchwerk
Thanks, this probably works. I test SetSpawnInfo but before toggle spectating
|
No problem mate. Feel free to post if you have any more questions or concerns.