Scripting a custom class selection
#3

Quote:
Originally Posted by jlalt
Посмотреть сообщение
PHP код:
    if(gInfo[currGame][gTotalClass] >= currSkin[playerid]) 
    { 
        
currSkin[playerid] = 1
    } 
if(4 >= 1) Yes!

PHP код:
    if(currSkin[playerid] >= gInfo[currGame][gTotalClass]) 
    { 
        
currSkin[playerid] = 1
    } 
if(1 >= 4) Yes! [ this is first check result, currSkin was always being reseted to 1 ]

however this is how you could've done it.
with this system players will be able to go to previous skin not only next.

PHP код:
#include a_samp
#define             MAX_GAMES               (500)
#define             MAX_CLASSES             (6)
// Game Mode Types
#define             GAME_TDM                (1)
#define             GAME_LMS                (2)
#define             GAME_RACE               (3)
#define             GAME_TAKEOVER           (4)
#define             GAME_STEALING           (5)
#define             GAME_ZOMBIE             (6)
#define             GAME_DM                 (7)
#define             GAME_FALLOUT            (8)
#define             GAME_BOMBING            (9)
enum GameInfo
{
    
gName[32],
    
gMode,
    
gRoundTime,
    
gSkin[MAX_CLASSES],
    
Float:gSkinX[MAX_CLASSES],
    
Float:gSkinY[MAX_CLASSES],
    
Float:gSkinZ[MAX_CLASSES],
    
Float:gSkinA[MAX_CLASSES],
    
gSkinInt[MAX_CLASSES],
    
gSkinVW[MAX_CLASSES],
    
gTotalClass
};
new
    
gInfo[MAX_GAMES][GameInfo],
    
gGames,
    
currGame,
    
currSkin[MAX_PLAYERS]
;
stock CreateGame(name[], modetime)
{
    if(
gGames >= MAX_GAMES)
        return 
printf("* Can't create a new game, Has reached the (%d) limit."MAX_GAMES);
    
gGames ++;
    
format(gInfo[gGames][gName], 32name);
    
gInfo[gGames][gMode] = mode;
    
gInfo[gGames][gRoundTime] = time;
    
gInfo[gGames][gTotalClass] = 0;
    for(new 
iMAX_CLASSESi++)
    {
        
gInfo[gGames][gSkin][i] = -1;
        
gInfo[gGames][gSkinX][i] = -1;
        
gInfo[gGames][gSkinY][i] = -1;
        
gInfo[gGames][gSkinZ][i] = -1;
        
gInfo[gGames][gSkinA][i] = -1;
        
gInfo[gGames][gSkinInt][i] = -1;
        
gInfo[gGames][gSkinVW][i] = -1;
    }
    return 
gGames;
}
stock AddPlayerClasses(gameidskinidFloat:xFloat:yFloat:zFloat:ainteriorworld)
{
    if(
gInfo[gameid][gTotalClass] >= MAX_CLASSES)
        return 
printf("* Can't add new classes, Has reached the (%d) limit."MAX_CLASSES);
    
gInfo[gameid][gSkin][gInfo[gameid][gTotalClass]] = skinid;
    
gInfo[gameid][gSkinX][gInfo[gameid][gTotalClass]] = x;
    
gInfo[gameid][gSkinY][gInfo[gameid][gTotalClass]] = y;
    
gInfo[gameid][gSkinZ][gInfo[gameid][gTotalClass]] = z;
    
gInfo[gameid][gSkinA][gInfo[gameid][gTotalClass]] = a;
    
gInfo[gameid][gSkinInt][gInfo[gameid][gTotalClass]] = interior;
    
gInfo[gameid][gSkinVW][gInfo[gameid][gTotalClass]] = world;
    return 
gInfo[gameid][gTotalClass] ++;
}
public 
OnGameModeInit()
{
    
SetGameModeText("Minigames v0.01");
    
AddPlayerClass(01699.9644, -3488.900920.7700353.1400000000);
    
AddPlayerClass(11699.9644, -3488.900920.7700353.1400000000);
    
AddPlayerClass(21699.9644, -3488.900920.7700353.1400000000);
    
////////////////////////////////////////////////////////////////////////////
    
CreateGame("Militia Forest"GAME_TDM300);
    
// Green Team
    
AddPlayerClasses(131699.9644, -3488.900920.7700353.140000);
    
AddPlayerClasses(11331699.9644, -3488.900920.7700353.140000);
    
AddPlayerClasses(11911699.9644, -3488.900920.7700353.140000);
    
// Blue Team
    
AddPlayerClasses(12851697.8439, -3198.130618.4751184.901800);
    
currGame 1;
    
////////////////////////////////////////////////////////////////////////////
    
return 1;
}
new 
FIRSTTIME[MAX_PLAYERS char], LastSkinZ[MAX_PLAYERS char];
public 
OnPlayerConnect(playerid)
{
    
FIRSTTIME[playerid] = 0;
    
LastSkinZ[playerid] = -1;
}
SetPlayerSkinEx(playerid, &classid)
{
    if(
classid >= gInfo[currGame][gTotalClass])
    {
        
classid 0;
    }
    if(
classid 0)
    {
        
classid gInfo[currGame][gTotalClass]-1;
    }
    
SetPlayerSkin(playeridgInfo[currGame][gSkin][classid]);
}
GetSkinEx(LastSkinenewskinz, &nextskinorprev)
{
    if(
LastSkine != -1)
    {
        if(
LastSkine == && newskinz == 0)
        {
            
nextskinorprev 1;
        }
        else if(
LastSkine == && newskinz == 2)
        {
            
nextskinorprev 0;
        }
        else if(
newskinz LastSkine)
        {
            
nextskinorprev 0;
        }
        else if(
newskinz LastSkine)
        {
            
nextskinorprev 1;
        }
    }
    else
    {
        
nextskinorprev 1;
    }
}
public 
OnPlayerRequestClass(playeridclassid)
{
    new 
what;
    
GetSkinEx(LastSkinZ[playerid], classidwhat);
    
LastSkinZ[playerid] = classid;
    if(
what 0)
    {
        if(
FIRSTTIME[playerid]) // fisrt time
        
{
            
FIRSTTIME[playerid] = 0;
            
SetPlayerSkinEx(playeridcurrSkin[playerid]);
        }
        else
        {
            
currSkin[playerid] ++;
            
SetPlayerSkinEx(playeridcurrSkin[playerid]);
        }
    }
    else
    {
        
currSkin[playerid] --;
        
SetPlayerSkinEx(playeridcurrSkin[playerid]);
    }
    
SetPlayerPos(playerid2495.04492773.056610.8158);
    
SetPlayerFacingAngle(playerid88.0);
    
SetPlayerCameraPos(playerid2490.95562773.132610.7968);
    
SetPlayerCameraLookAt(playerid2495.04492773.056610.8158);
    
PlayerPlaySound(playerid10682495.04492773.056610.8158);
    switch(
random(5))
    {
        case 
0ApplyAnimation(playerid"DANCING""dnce_M_a"4.110000);
        case 
1ApplyAnimation(playerid"DANCING""dnce_M_b"4.110000);
        case 
2ApplyAnimation(playerid"DANCING""dnce_M_c"4.110000);
        case 
3ApplyAnimation(playerid"DANCING""dnce_M_d"4.110000);
        case 
4ApplyAnimation(playerid"DANCING""dnce_M_e"4.110000);
    }
    return 
1;

I kinda like the code you did there but I saw that one of your function depends on the classid, But classid were never used on the script (Besides having one class which is CJ). The rest of the class selection works by checking if player's variable has reached the maximum available of class to that game, I would like to modify the code but I have no idea how the function works lol.
Reply


Messages In This Thread
Scripting a custom class selection - by JaKe Elite - 20.12.2016, 12:37
Re: Scripting a custom class selection - by jlalt - 20.12.2016, 14:03
Re: Scripting a custom class selection - by JaKe Elite - 20.12.2016, 20:37
Re: Scripting a custom class selection - by jlalt - 21.12.2016, 04:03
Re: Scripting a custom class selection - by JaKe Elite - 24.12.2016, 00:03
Re: Scripting a custom class selection - by jlalt - 24.12.2016, 05:19
Re: Scripting a custom class selection - by Sew_Sumi - 24.12.2016, 07:51
Re: Scripting a custom class selection - by JaKe Elite - 24.12.2016, 07:56
Re: Scripting a custom class selection - by jlalt - 24.12.2016, 12:08
Re: Scripting a custom class selection - by Sew_Sumi - 24.12.2016, 13:04

Forum Jump:


Users browsing this thread: 3 Guest(s)