29.08.2018, 16:32
Hello, how do i load the clan when the player requests his class, here's my code:
PHP код:
CMD:createclan(cmdid, playerid, params[])
{
if(UserStats[playerid][Kills] < 1000) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You must have 1000+ kills to create a clan.");
new clanname[32], string[300], query[600], rows;
if(sscanf(params, "s[32]", clanname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /createclan [clanname]");
mysql_format(Database, query, sizeof(query), "SELECT * FROM `clans` WHERE `ClanName` = '%e' LIMIT 0, 1", clanname);
new Cache:result = mysql_query(Database, query);
cache_get_row_count(rows);
if(rows)
{
SendClientMessage(playerid, COLOR_RED, "[SERVER]: That clan name is already registered by someone else.");
return 0;
}
for (new i = 0; i < rows; i ++)
{
mysql_format(Database, query, sizeof(query), "INSERT INTO `clans` (`ClanName`, `Leader`, `Official`) VALUES ('%e', '%e', '0')", clanname, GetName(playerid));
mysql_tquery(Database, query);
format(string, sizeof(string), "[SERVER]: You have created a unofficial clan named %s.", clanname);
SendClientMessage(playerid, COLOR_RED, string);
format(string, sizeof(string), "Clan Name: %s, Official: No", clanname);
SendClientMessage(playerid, COLOR_RED, string);
UserStats[playerid][Clan] = cache_insert_id();
}
cache_delete(result);
return 1;
}
PHP код:
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1869.176269, -1362.816650, 19.140625);
SetPlayerFacingAngle(playerid, 233.139862);
SetPlayerCameraLookAt(playerid, 1869.176269, -1362.816650, 19.140625);
SetPlayerCameraPos(playerid, 1869.176269 + (10 * floatsin(-233.139862, degrees)), -1362.816650 + (10 * floatcos(-233.139862, degrees)), 19.140625);
switch(classid)
{
case 0:
{
GameTextForPlayer(playerid, "~y~La Raza", 1000, 4);
Team[playerid] = TEAM_LARAZA;
SetPlayerTeam(playerid, TEAM_LARAZA);
}
case 1:
{
GameTextForPlayer(playerid, "~y~Wah Ching", 1000, 4);
Team[playerid] = TEAM_WAHCHING;
SetPlayerTeam(playerid, TEAM_WAHCHING);
}
case 2:
{
GameTextForPlayer(playerid, "~y~La Cosa Nostra", 1000, 4);
Team[playerid] = TEAM_LACOSANOSTRA;
SetPlayerTeam(playerid, TEAM_LACOSANOSTRA);
}
case 3:
{
GameTextForPlayer(playerid, "~y~Special Forces", 1000, 4);
Team[playerid] = TEAM_SPECIALFORCES;
SetPlayerTeam(playerid, TEAM_SPECIALFORCES);
}
case 4:
{
if(UserStats[playerid][Clan])
{
new string[250], cid, query[250];
mysql_format(Database, query, sizeof(query), "SELECT * FROM `clans` WHERE `ClanID` = '%i' LIMIT 0, 1", cid);
new Cache:result = mysql_query(Database, query);
for (new i = 0; i < MAX_CLANS; i ++)
{
format(string, sizeof(string), "%s", ClanInfo[i][ClanName]);
GameTextForPlayer(playerid, string, 1000, 4);
}
cache_delete(result);
}
else
{
GameTextForPlayer(playerid, "~r~YOU ARE NOT IN A CLAN", 1000, 4);
Team[playerid] = NOTINCLAN;
}
}
}
return true;
}