26.04.2013, 15:23
Here's a function which I just created. It's about getting player's class. It auto-sets the class under 'OnPlayerRequestClass' and also sets even if the classes are switched under 'OnPlayerRequestClass' as it's being called on every switches. It's hooked and also provided with 'SetPlayerClass' in case if required to set the player's class. You don't need to SetPlayerClass under OnPlayerRequestClass, as it's already done and hooked.
Some examples:
pawn Код:
new L_PlayerClass_[MAX_PLAYERS];
stock SetPlayerClass(playerid, classid)
{
L_PlayerClass_[playerid] = classid;
return 1;
}
stock GetPlayerClass(playerid)
{
return L_PlayerClass_[playerid];
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerClass(playerid, classid);
CallLocalFunction("L_OnPRC", "ii", playerid, classid);
return 1;
}
forward L_OnPRC(playerid, classid);
#if defined _ALS_OnPlayerRequestClass
#undef OnPlayerRequestClass
#else
#define _ALS_OnPlayerRequestClass
#endif
#define OnPlayerRequestClass L_OnPRC
Some examples:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
printf("Class: %d", GetPlayerClass(playerid));
return 1;
}
public OnPlayerSpawn(playerid)
{
printf("Spawn Class: %d", GetPlayerClass(playerid));
return 1;
}