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;
}
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;
}
Hello, how do i load the clan when the player requests his class
|
If you're logging them in, if it's a player saved stat, then you load them before they even request the class.
Also, be clear on where infact you want this, as request class, is when they are going through the skin selection, not requesting spawn. If you allow this, someone could sit in the spawn window, and change classes, seeing all the teams chats. Alright, now I've come back to looking at your code.... (because the spawn window has so much capability, no-one actually uses it, and when they do changes to it, they BREAK it, and it causes problems elsewhere in the script, and to be sure of this, I took your code out, to look at after I had made the above) No... Just no, you should revise this, as really, if it is after them logging in, then when they are logging in, is where you should be loading their clan into their enum. You should only set the team associations on spawn in a class selection screen, and when they are in that window, they should be not getting any of those messages anyway, or anything, as they aren't 'in the game'. |
You could put all skins into the class selection, and restrict their spawn based on the clan ID on the skin compared to their membership, or you could simply have a claude skin, which is a placeholder to allow them to get past the screen, and when they select the spawn, then have them set to their clan setup.
And in respects of the claude placeholder, have NPCs in an area, with different skins for each clan on, and make the camera look at whatever their clan NPC is. There will be many different ways to do this sort of thing. But I'm sure that the idea of changing the skin of a class whilst in the class selection screen, isn't likely to be possible. I may be wrong, but the throw-outs above of ideas, could help you in thinking from another angle, and checking out other things. |
case 4:
{
if(UserStats[playerid][Clan]=>0)
{
new string[100];
format(string, sizeof(string), "%s", ClanInfo[UserStats[playerid][Clan]][ClanName]);
GameTextForPlayer(playerid, string, 1000, 4);
//you must have loaded all clan names before somewhere
}
else
{
GameTextForPlayer(playerid, "~r~YOU ARE NOT IN A CLAN", 1000, 4);
return 0; //prevents the player from spawning
}
}
First thing i will say, you must set UserStats[playerid][Clan] by default value to -1 because 0 can be a valid clan id, then in your code:
PHP код:
|
new string[100];
format(string, sizeof(string), "%s", ClanInfo[UserStats[playerid][Clan]][ClanName]);
GameTextForPlayer(playerid, string, 1000, 4);
format(string, sizeof(string), "Clan name: %s", ClanInfo[UserStats[playerid][Clan]][ClanName]);
SendClientMessage(playerid, -1, string);
Did you notice this part?
Try to debug the string PHP код:
|
new string[100];
format(string, sizeof(string), "%s", ClanInfo[UserStats[playerid][Clan]][ClanName]);
GameTextForPlayer(playerid, string, 1000, 4);
format(string, sizeof(string), "Clan ID: %d", UserStats[playerid][Clan]);
SendClientMessage(playerid, -1, string);