Need help with Male/Female selection on register. -
I need some help with my register system.
I am trying to add a Male/Female selection dialog which indeed works.
But I just can't figure out how i can make the player spawn with his skin.
So lets say the player is a female, she would need to have a female skin and spawn at spawn.
If the the player is a male, he selects the male skin which will be spawned at the same spawn.
Код:
/*========================================================================================*/
/* Valor RPG By Valor */
/* Project Started: 12/15/2014 */
/*========================================================================================*/
/*=====================================[ Includes ]=======================================*/
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
/*=====================================[ Defines ]========================================*/
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_GENDER 3
#define UserPath "Users/%s.ini"
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
/*=====================================[ Natives ]========================================*/
native WP_Hash(buffer[],len,const str[]);
/*=======================================[ Enum ]=========================================*/
enum PlayerInfo
{
Pass[129],
Level,
Money,
Sex
}
new pInfo[MAX_PLAYERS][PlayerInfo];
forward loadaccount_user(playerid, name[], value[]);
/*=======================================[ Start ]=========================================*/
main()
{
print(" --------------------");
print(" Valor RPG Loading..");
print(" Gamemode By Valor ");
print(" --------------------");
}
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129);
INI_Int("Level",pInfo[playerid][Level]);
INI_Int("Money",pInfo[playerid][Money]);
INI_Int("Sex",pInfo[playerid][Sex]);
return 1;
}
public OnGameModeInit()
{
SetGameModeText("Valor RPG v0.1a");
AddPlayerClass(3, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0); //Male Skin
AddPlayerClass(40, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0); //Female Skin
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME], string[128], string2[128];
GetPlayerName(playerid, name, sizeof(name));
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
format(string, sizeof(string), "{AFAFAF}Bun venit {8A73DE}%s{AFAFAF}!\nContul acesta a fost deja inregistrat.\nVa rugam sa introduceti parola.", name);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Valor: Login",string,"Login","Quit");
}
else
{
format(string2, sizeof(string2), "{AFAFAF}Bun venit {8A73DE}%s{AFAFAF}!\nContul acesta nu este in registrat.\nVa rugam sa introduceti o parola\npentru a va inregistra.", name);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Valor: Register",string2,"Register","Quit");
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Level",GetPlayerScore(playerid));
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Sex",pInfo[playerid][Sex]);
INI_Close(file);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(response)
{
new pwlength = strlen(inputtext);
if(pwlength > 0)
{
ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_LIST, "Gender", "Male\nFemale", "Next", "Cancel");
switch(listitem)
{
new MALESKIN = AddPlayerClass(3, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0); //Male Skin
new FEMALESKIN = AddPlayerClass(40, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0); //Female Skin
case 0: //Male
{
pInfo[playerid][Sex] = 1;
SetSpawnInfo(playerid, 0, 3, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0);
}
case 1: //Female
{
pInfo[playerid][Sex] = 2;
SetSpawnInfo(playerid, 0, 40, 1685.0341, -1343.4779, 17.4349, 274.0744, 0, 0, 0, 0, 0, 0);
}
}
}
else
{
new name[MAX_PLAYER_NAME], string[128];
format(string, sizeof(string), "{AFAFAF}Bun venit {8A73DE}%s{AFAFAF}!\nContul acesta nu este in registrat.\nVa rugam sa introduceti o parola\npentru a va inregistra.", name);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Valor: Register",string,"Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass), inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"Level",0);
INI_WriteInt(file,"Money",25000);
INI_Close(file);
return 1;
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass, sizeof(hashpass),inputtext);
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
GivePlayerMoney(playerid,pInfo[playerid][Money]);
}
else
{
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "{AFAFAF}Bun venit {8A73DE}%s{AFAFAF}!\nContul acesta a fost deja inregistrat.\nVa rugam sa introduceti parola.", name);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Valor: Login",string,"Login","Quit");
}
}
}
if(dialogid == DIALOG_GENDER)
{
if(!response) return Kick(playerid);
if(response)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "Sex", listitem);
INI_Close(file);
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
Re: Need help with Male/Female selection on register. -
I quickly checked your code and there's no call to spawn the player, perharps that's what is missing