Limit the range of classes
#1

Hi, i need a help with the AddPlayerClass, i create a gamemode with account and character system, when i enter, the characters are loaded in the AddPlayerClass, but if i select the player class i can go to 9999999999 player class, i need limit the range of player class for only loaded characters!

Someone?
Reply
#2

Maybe return 0 on a check? [Just an opinnion]
Example:
pawn Код:
public OnPlayerRequestClass(playerid, classid) {
  if(classid > player_variable[how_much_caracters_do_your_player_have] || classid < 0) // if current classid=current caracter is bigger than the numbers of caracters a player can have, or if the current class is < 0 then....
       return 0; // return 0, it means it can pres on >>, or  << anymore.
  return 1;
}
There are some many things you have to discover on yourself, I have the ideea but I dont think its matches your system and gamemode.
Reply
#3

I had already tried this but it did not work !
pawn Код:
if(classid < 0) return 0;
    if(classid > 2) return 0;
Reply
#4

You tried to set the player's skin to the player caracter's skin in Classes Selection, if the player is registered?? like:
pawn Код:
SetPlayerSkin(playerid, P_Caracter[playerid][CaracterSkin]);
The code you did is good, but that just prevent the user from going any further from the limits. (Its not bad)
You must set the player's skin in current classes from the accounts's skin, wich I hope you have a saving system for that. also AddPlayerClass is out of option if you uses caracters with accounts, The script will monstly depends on the variable you created.

Example:

(1).Johm enters the server, he have a total of 6 caracters limits on his account. Each one has the skin of CJ.
You must set the limits between 0 and player's amount of max caracters (6 in this case)

(2). John enters the server, he have a total fo 6 caracters limits on his account, All of them has different skins, wich means we must set the classes that he watch (preview) (and that class represents the id of Classid in your OnGameModeInit, example: you have 3 AddPlayerClass, 22, 44, 33: there will be 3 ids, 1: 22, 2: 44, 3: 33, the current classid paramter, if classid == 1, it means classid == 22)
So we set the current skin that he watch being = to the id skin of the same number id of the account.

Example:

(1)Caracter 1: he have CJ
(2)C 2: Cop skn
(3)C 3: SWAT skin

Set the current skin = Your_Variable[playerid][CaracterSkin[classid]];
Reply
#5

I am seriously considering using this

pawn Код:
if(classid < 0) {
    //Load classid 0
} else if(classid > 2) {
   //Load Classid 2
}
Reply
#6

Yeah its a good thing considering your max amount of caracter is = 2. but I sugges not to use else if, just use else
Reply
#7

Someone with other method?
Reply
#8

do like this

at top

new Classes[] = {1,2,3,4,5,6}; //skins 1,2,3,4,5,6 is skins you want to use


under ongamemodeinit add

for(new i; i < sizeof(Classes); i++)
{
AddPlayerClass(i,....);
}

and in class selection, it will never go out of bounds.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)