Help a fellow Newbie Programmer..
#3

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
After you save the skin ID to a database, load it into a variable under 'OnAccountLoad' and use SetPlayerSkin under OnPlayerSpawn, like so:
Код:
public OnPlayerSpawn(playerid)
{
    if (Player[playerid][ID] > 0) // check if player is registered
    {
        SetPlayerSkin(playerid, Player[playerid][SkinID]);
    }
    return 1;
}
Or use it directly as the third parameter in SetSpawnInfo defines with which skin ID they spawn.

Edit: I admit, I half-misread what you wanted there.
To let players have some way of selecting a skin, you have two options: use the old way, or the new way.

The old way is maybe more complicated, but you still have to use some part of it.
The old way consisted of this: you add the classes (skins with predefined weapons as they spawn etc.) under OnGameModeInit (when the server loads) then under OnPlayerRequestClass (when they get to choose the skin) you set their camera position to look at the skin to select and they choose it with '<<' '>>' buttons. I can't explain it to you any better, go take a look at the 'grandlarc.pwn' (Grand Larceny) game mode included with the server.

The new way is with text draws. You show the player a text draw menu with skin models and they choose which one they want with a simple mouse click! See here.
I seem to have missed a few things/points that are vital for such Support Request:

Im working on a Roleplay gamemode, we all know that Skin Selection isn't a thing on most RP servers since we (Developers), choose to have the backpacker as default skin. The problem is that i have no single clue on how to integrate part of that stuff on my MySQL Query.

My Enum:

Код:
enum PlayerData 
{ 
    ID, 
    Name[MAX_PLAYER_NAME], 
    Password[129], 
    IP[16], 
    Admin, 
    VIP, 
    Money,  
    SkinID,
    Float:PosX, 
    Float:PosY, 
    Float:PosZ, 
    Float:PosA
}; 
new Player[MAX_PLAYERS][PlayerData];
My SQL Query:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{ 
    switch(dialogid) 
    { 
        case LoginDialog: 
        { 
            if(!response) Kick(playerid); 
             
            new 
                hashpass[129], 
                query[100], 
                playername[MAX_PLAYER_NAME]; 

            GetPlayerName(playerid, playername, sizeof(playername)); 
            WP_Hash(hashpass, sizeof(hashpass), inputtext); 
            if(!strcmp(hashpass, Player[playerid][Password])) 
            { 
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername); 
                mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid); 
            } 
            else 
            { 
                SendClientMessage(playerid, -1, "Incorrect Password, try again."); 
                ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Sign in", "You seem to have an account on our server. \nPlease, type your password to log in:", "Login", "Quit"); 
            } 
        } 
        case RegisterDialog: 
        { 
            if(!response) return Kick(playerid); 
            if(strlen(inputtext) < 5) 
            { 
                SendClientMessage(playerid, -1, "Your password needs to have more than 4 characters."); 
                return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Sign up", "Mmm.. seems like you don't have an account. \nPlease, type a password:", "Next", "Quit");  
            } 
            new 
                query[512], 
                playername[MAX_PLAYER_NAME], 
                playerip[16]; 
                 

            GetPlayerName(playerid, playername, sizeof(playername)); 
            GetPlayerIp(playerid, playerip, sizeof(playerip)); 
            WP_Hash(Player[playerid][Password], 129, inputtext); 
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A); 
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid); 
        } 
    } 
    return 0; // 
}
OnPlayerDisconnect (Saving stuff after disconnect)
Код:
public OnPlayerDisconnect(playerid, reason) 
{ 
    new 
        query[128], 
        Float:Pos[4]; 
         
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); 
    GetPlayerFacingAngle(playerid, Pos[3]); 
     
    mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f WHERE `ID` = %d", 
    GetPlayerMoney(playerid), Pos[0], Pos[1], Pos[2], Pos[3], Player[playerid][ID]); 
    mysql_tquery(mysql, query, "", ""); 
     
    return 1; 
}
Also, i want to make use of a defined variable (like it has been done with the SPAWN_Z, etc), in this case for my Default Skin set for new accounts on registration:

Код:
#define DEFAULT_SKIN (26)
If anybody knows how to achieve that, i will (again) appreciate that.
Reply


Messages In This Thread
Help a fellow Newbie Programmer.. - by SparkyCode - 31.08.2015, 09:34
Re: Help a fellow Newbie Programmer.. - by Virtual1ty - 31.08.2015, 10:19
Re: Help a fellow Newbie Programmer.. - by SparkyCode - 31.08.2015, 14:18
Re: Help a fellow Newbie Programmer.. - by Sjn - 31.08.2015, 14:34
Re: Help a fellow Newbie Programmer.. - by xVIP3Rx - 31.08.2015, 15:05
Re: Help a fellow Newbie Programmer.. - by SparkyCode - 31.08.2015, 15:30
Re: Help a fellow Newbie Programmer.. - by xVIP3Rx - 31.08.2015, 15:40
Re: Help a fellow Newbie Programmer.. - by SparkyCode - 31.08.2015, 21:52
Re: Help a fellow Newbie Programmer.. - by xVIP3Rx - 31.08.2015, 23:52

Forum Jump:


Users browsing this thread: 1 Guest(s)