How to load the clan onplayerrequestclass
#1

Hello, how do i load the clan when the player requests his class, here's my code:

PHP код:
CMD:createclan(cmdidplayeridparams[])
{
    if(
UserStats[playerid][Kills] < 1000) return SendClientMessage(playeridCOLOR_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(playeridCOLOR_RED"[USAGE]: /createclan [clanname]");
    
mysql_format(Databasequerysizeof(query), "SELECT * FROM `clans` WHERE `ClanName` = '%e' LIMIT 0, 1"clanname);
    new 
Cache:result mysql_query(Databasequery);
    
cache_get_row_count(rows);
    
    if(
rows)
    {
        
SendClientMessage(playeridCOLOR_RED"[SERVER]: That clan name is already registered by someone else.");
        return 
0;
    }
    
    for (new 
0rows++)
    {
        
mysql_format(Databasequerysizeof(query), "INSERT INTO `clans` (`ClanName`, `Leader`, `Official`) VALUES ('%e', '%e', '0')"clannameGetName(playerid));
        
mysql_tquery(Databasequery);
        
format(stringsizeof(string), "[SERVER]: You have created a unofficial clan named %s."clanname);
        
SendClientMessage(playeridCOLOR_REDstring);
        
format(stringsizeof(string), "Clan Name: %s, Official: No"clanname);
        
SendClientMessage(playeridCOLOR_REDstring);
        
UserStats[playerid][Clan] = cache_insert_id();
    }
    
cache_delete(result);
    return 
1;

PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1869.176269, -1362.81665019.140625);
    
SetPlayerFacingAngle(playerid233.139862);
    
SetPlayerCameraLookAt(playerid1869.176269, -1362.81665019.140625);
    
SetPlayerCameraPos(playerid1869.176269 + (10 floatsin(-233.139862degrees)), -1362.816650 + (10 floatcos(-233.139862degrees)), 19.140625);
    switch(
classid)
    {
        case 
0:
        {
            
GameTextForPlayer(playerid"~y~La Raza"10004);
            
Team[playerid] = TEAM_LARAZA;
            
SetPlayerTeam(playeridTEAM_LARAZA);
        }
        case 
1:
        {
            
GameTextForPlayer(playerid"~y~Wah Ching"10004);
            
Team[playerid] = TEAM_WAHCHING;
            
SetPlayerTeam(playeridTEAM_WAHCHING);
        }
        case 
2:
        {
            
GameTextForPlayer(playerid"~y~La Cosa Nostra"10004);
            
Team[playerid] = TEAM_LACOSANOSTRA;
            
SetPlayerTeam(playeridTEAM_LACOSANOSTRA);
        }
        case 
3:
        {
            
GameTextForPlayer(playerid"~y~Special Forces"10004);
            
Team[playerid] = TEAM_SPECIALFORCES;
            
SetPlayerTeam(playeridTEAM_SPECIALFORCES);
        }
        case 
4:
        {
            if(
UserStats[playerid][Clan])
            {
                new 
string[250], cidquery[250];
                
mysql_format(Databasequerysizeof(query), "SELECT * FROM `clans` WHERE `ClanID` = '%i' LIMIT 0, 1"cid);
                new 
Cache:result mysql_query(Databasequery);
                
                for (new 
0MAX_CLANS++)
                {
                    
format(stringsizeof(string), "%s"ClanInfo[i][ClanName]);
                    
GameTextForPlayer(playeridstring10004);
                }
                
cache_delete(result);
            }
            else
            {
                
GameTextForPlayer(playerid"~r~YOU ARE NOT IN A CLAN"10004);
                
Team[playerid] = NOTINCLAN;
            }
        }
    }
    return 
true;

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)