PDA

View Full Version : OnPlayerRequestClass help


Zunno
28/12/2011, 07:02 AM
Hello,
I have a problem with my Script.
When i press F4 on my Server, i came on the ClassSelection, but when i press the Spawn Button, i Spawn and came back to the ClassSelection.

My OnPlayerRequestClass Public:
public OnPlayerRequestClass(playerid, classid)
{
print("OnPlayerRequestClass called...");
SpawnPlayer(playerid);
return 1;
}

I hope someone has a solution for my problem.

/Edit: I use SA-MP 0.3d R1, and this problem i had it in 0.3c too.

* Zunno

Ironboy
28/12/2011, 07:07 AM
Show the code "OnPlayerSpawn"

Zunno
28/12/2011, 07:16 AM
OnPlayerSpawn:
public OnPlayerSpawn(playerid)
{
SetCameraBehindPlayer(playerid);
SetPlayerTextLabel(playerid);
if(GetPVarInt(playerid, "FreezeTime") == 0) { TogglePlayerControllable(playerid, 1); }
InitLockDoors(playerid);
STDPlayer[playerid] = 0;
gTeam[playerid] = PlayerInfo[playerid][pTeam];
if(gTeam[playerid] == 4) { gTeam[playerid] = 3; }
//if(IsPlayerNPC(playerid)) { Eingeloggt[playerid] = 1; }
if(GetPVarInt(playerid, "TBan") > 0) { DeletePVar(playerid, "TBan"); }
if(Eingeloggt[playerid] == 0 && !IsPlayerNPC(playerid)) { SendClientMessage(playerid, COLOR_LIGHTRED, "** This server requires a login before spawning! **"); Kick(playerid); }
//if(GetPVarInt(playerid, "AtClothes") == 1) { PlayerInfo[playerid][pModel] = GetPlayerSkin(playerid); DeletePVar(playerid, "AtClothes"); }
if(gTeam[playerid] == 3)
{
if(PlayerInfo[playerid][pMember] > 0 || PlayerInfo[playerid][pLeader] > 0)
{
new model = GetPVarInt(playerid, "Char");
if(PlayerInfo[playerid][pMember] == 1) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pMember] == 2) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pMember] == 3) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pMember] == 4) { SetSpawnInfo(playerid, 1, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 1; gTeam[playerid] = 1; }
else if(PlayerInfo[playerid][pMember] == 5) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
else if(PlayerInfo[playerid][pMember] == 6) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
else if(PlayerInfo[playerid][pMember] == 7) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pMember] == 8) { SetSpawnInfo(playerid, 10, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 10; gTeam[playerid] = 10; }
else if(PlayerInfo[playerid][pMember] == 9) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 10) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 11) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 12) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 13) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 14) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 15) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 16) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 17) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pMember] == 18) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 1) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pLeader] == 2) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pLeader] == 3) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pLeader] == 4) { SetSpawnInfo(playerid, 1, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 1; gTeam[playerid] = 1; }
else if(PlayerInfo[playerid][pLeader] == 5) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
else if(PlayerInfo[playerid][pLeader] == 6) { SetSpawnInfo(playerid, 5, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 5; gTeam[playerid] = 5; }
else if(PlayerInfo[playerid][pLeader] == 7) { SetSpawnInfo(playerid, 2, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 2; gTeam[playerid] = 2; }
else if(PlayerInfo[playerid][pLeader] == 8) { SetSpawnInfo(playerid, 10, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 10; gTeam[playerid] = 10; }
else if(PlayerInfo[playerid][pLeader] == 9) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 10) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 11) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 12) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 13) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 14) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 15) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 16) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 17) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
else if(PlayerInfo[playerid][pLeader] == 18) { SetSpawnInfo(playerid, 12, model,0.0,0.0,0.0,0,0,0,0,0,0,0); PlayerInfo[playerid][pTeam] = 12; gTeam[playerid] = 12; }
SpawnPlayer(playerid);
}
}
if(PlayerInfo[playerid][pMember] > 0 || PlayerInfo[playerid][pLeader] > 0) { SetPlayerSkin(playerid, GetPVarInt(playerid, "Char")); }
else { SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]); }

if(!gPlayerAnimLibsPreloaded[playerid])
{
PreloadAnimLib(playerid,"BOMBER");
PreloadAnimLib(playerid,"RAPPING");
PreloadAnimLib(playerid,"SHOP");
PreloadAnimLib(playerid,"BEACH");
PreloadAnimLib(playerid,"SMOKING");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"ON_LOOKERS");
PreloadAnimLib(playerid,"DEALER");
PreloadAnimLib(playerid,"CRACK");
PreloadAnimLib(playerid,"CARRY");
PreloadAnimLib(playerid,"COP_AMBIENT");
PreloadAnimLib(playerid,"PARK");
PreloadAnimLib(playerid,"INT_HOUSE");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"PED");
gPlayerAnimLibsPreloaded[playerid] = 1;
}
if(AntiSpawnKill[playerid] == false)
{
SetTimerEx("AntiSpawnKillTimer", 10000, 0, "i", playerid);
AntiSpawnKill[playerid] = true;
SetPlayerHealth(playerid, 999999.99);
TextDrawShowForPlayer(playerid, AntiKill);
}
//
SetPlayerWeapons(playerid);
SetPlayerSpawn(playerid);
SetPlayerToTeamColor(playerid);
PlayerFixRadio(playerid);
return 1;
}

MP2
28/12/2011, 07:24 AM
Hello,
I have a problem with my Script.
When i press F4 on my Server, i came on the ClassSelection, but when i press the Spawn Button
So SpawnPlayer isn't actually working under OnPlayerRequestClass. Try a timer of about 100 MS.

Zunno
28/12/2011, 07:28 AM
Okay I'll try

/Edit: it doesn't work :(

my code now:
public OnPlayerRequestClass(playerid, classid)
{
print("OnPlayerRequestClass called...");
//SpawnPlayer(playerid);
SetTimerEx("ZSpawn",100,0,"i",playerid);
return 1;
}

public ZSpawn(playerid)
{
return SpawnPlayer(playerid);
}


But even if I'm standing there, nothing inside, I'll post the press the spawn button again sent into the skin selection. Furthermore, I'll be right after I F4 in the skin selection, and not next to the dead.

Ironboy
28/12/2011, 07:50 AM
The problem happent only when you press F4 for the class selection?

Zunno
28/12/2011, 07:54 AM
yes exactly.
I don't know why this is so.

Ironboy
28/12/2011, 08:25 AM
I cant find anything from the script.
I suggest you to use ForceClassSelection
if (strcmp("/class", cmdtext, true, 10) == 0)
{
ForceClassSelection(playerid);
SendClientMessage(playerid, 0xAA3333AA,"[CLASS]> You have been forced to the class selection");
SetPlayerHealth(playerid, 0.00);
return 1;
}
OR
CMD:class(playerid,params[]){
ForceClassSelection(playerid);
SendClientMessage(playerid, 0xAA3333AA,"[CLASS]> You have been forced to the class selection");
SetPlayerHealth(playerid, 0.00);
return 1;}

AustinJ
28/12/2011, 08:29 AM
One solution could be not use to use GF as a script.

Zunno
28/12/2011, 08:29 AM
Yes but, the problem is, if someone provided on F4 comes, he must make a relog out because he does not anymore from the skin selection.

Edit:
Yes but i work now 1 year on the script, and now even to start a self-made is quite time consuming if you have a running server