24.03.2017, 09:25
I wanted to make a random Skins according to gender, but I do not run what wrong with my script?
This my script:
The mistake is to register every time always use skin id 0
This my script:
PHP код:
new Male[] = {
1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,
42,43,44,45,46,47,48,49,50,51,52,57,58,59,60,61,62,66,67,68,72,73,78,79,80,81,82,83,84,86,
94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,
118,119,120,121,122,123,124,125,126,127,128,132,133,134,135,136,137,142,143,144,146,147,149,
153,154,156,158,159,160,161,162,163,164,165,166,167,168,170,171,173,174,175,176,177,179,180,
181,182,183,184,185,186,187,188,189,200,202,203,204,206,208,209,210,212,213,217,220,221,222,
223,227,228,229,230,234,235,236,239,240,241,242,247,248,249,250,253,254,255,258,259,260,261,262,
268,269,270,271,272,273,289,290,291,292,293,294,295,296,297,299
};
new Female[] = {
9,10,11,12,13,31,39,40,41,53,54,55,56,63,64,65,69,75,76,77,85,87,88,89,90,91,92,93,129,130,131,
138,139,140,141,145,148,150,151,152,157,169,172,178,190,191,192,193,194,195,196,197,198,199,201,
205,207,211,214,215,216,218,219,224,225,226,231,232,233,237,238,243,244,245,246,251,256,257,263,298,
};
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
case GenderDialog:
{
if(!response) return ShowPlayerDialog(playerid, BloodDialog, DIALOG_STYLE_LIST,"{FF0000}Character Blood","{FFFFFF}A\nB\nAB\nO","Choose","Back");
if(response)
{
switch(listitem)
{
case 0:
{
new query[512],
playername[MAX_PLAYER_NAME],
playerip[16];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerIp(playerid, playerip, sizeof(playerip));
format(Player[playerid][Gender], 255, "Male");
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Age`, `Blood`, `Gender`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', '%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, Player[playerid][Age], Player[playerid][Blood], Player[playerid][Gender], SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
SetPlayerSkin(playerid, Male[random(195)]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
return 1;
}
case 1:
{
new query[512],
playername[MAX_PLAYER_NAME],
playerip[16];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerIp(playerid, playerip, sizeof(playerip));
format(Player[playerid][Gender], 255, "Female");
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Age`, `Blood`, `Gender`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', '%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, Player[playerid][Age], Player[playerid][Blood], Player[playerid][Gender], SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
SetPlayerSkin(playerid, Female[random(89)]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
return 1;
}
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
new name[MAX_PLAYER_NAME];
new string[500];
GetPlayerName(playerid,name,sizeof(name));
Player[playerid][ID] = cache_insert_id();
printf("[Registration] New account registered. Database ID: [%d]", Player[playerid][ID]);
SetSpawnInfo(playerid, 0, 0, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A, 0, 0, 0, 0, 0, 0);
SetPlayerSkin(playerid, Player[playerid][Gender]);
SpawnPlayer(playerid);
format(string, sizeof(string), "{0000CD}[SERVER] {FFFFFF}Welcome New Player {00FF00}%s, {FFFFFF}you are registered now.", name);
SendClientMessage(playerid, -1, string);
return true;
}