What's wrong with this command?
#1

pawn Код:
CMD:setclass(playerid, params[])
{
    new NewClass[24];
    if(sscanf(params, "s[24]", NewClass)) return SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}/setclass [classname]");

    if(strcmp(NewClass, "Taxi", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}{FFFFFF}You are already playing as a cab driver!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a taxi driver.");
        SetPlayerColor(playerid, COLOR_YELLOW);
        ResetPlayerWeapons(playerid);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerSkin(playerid, 234);
        SetPlayerPos(playerid, 1690.7296, 1447.7753, 10.7661);
        SetPlayerFacingAngle(playerid, 267.7922);
        PlayerClass[playerid] = 0;
    }
    else if(strcmp(NewClass, "Pilot", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}{FFFFFF}You are already playing as a pilot!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a pilot.");
        SetPlayerColor(playerid, COLOR_CYAN);
        ResetPlayerWeapons(playerid);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerSkin(playerid, 61);
        SetPlayerPos(playerid, 1319.2111, 1256.2635, 10.8203);
        SetPlayerFacingAngle(playerid, 359.9823);
        PlayerClass[playerid] = 1;
    }
    else if(strcmp(NewClass, "Paramedic", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 2) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}You are already playing as a paramedic!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a paramedic.");
        SetPlayerColor(playerid, COLOR_RED);
        ResetPlayerWeapons(playerid);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerSkin(playerid, 275);
        SetPlayerPos(playerid, 1607.5043, 1819.6926, 10.8280);
        SetPlayerFacingAngle(playerid, 359.0171);
        PlayerClass[playerid] = 2;
    }
    else if(strcmp(NewClass, "Lowlife", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 3) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}You are already playing as a lowlife!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a lowlife.");
        SetPlayerColor(playerid, COLOR_WHITE);
        ResetPlayerWeapons(playerid);
        SetPlayerArmour(playerid, 50);
        SetPlayerHealth(playerid, 100);
        GivePlayerWeapon(playerid, PISTOL, 256);
        GivePlayerWeapon(playerid, TEC9, 512);
        SetPlayerSkin(playerid, 292);
        SetPlayerPos(playerid, 1927.6666, 674.5269,  10.8203);
        SetPlayerFacingAngle(playerid, 0.0902);
        PlayerClass[playerid] = 3;
    }
    else if(strcmp(NewClass, "Firefighter", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 4) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}You are already playing as a firefighter!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a firefighter.");
        SetPlayerColor(playerid, COLOR_ORANGE);
        ResetPlayerWeapons(playerid);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerSkin(playerid, 278);
        SetPlayerPos(playerid, 1735.5243, 2111.2268, 12.2891);
        SetPlayerFacingAngle(playerid, 94.0980);
        PlayerClass[playerid] = 4;
    }
    else if(strcmp(NewClass, "Police", false, sizeof(NewClass)))
    {
        if(PlayerClass[playerid] == 5) return SendClientMessage(playerid, COLOR_RED, "(ERROR): {FFFFFF}You are already playing as a police officer!");
        SendClientMessage(playerid, COLOR_GRAY, "{7FAFDA}Server: {FFFFFF}You have respawned as a police officer.");
        SetPlayerColor(playerid, COLOR_BLUE);
        ResetPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, PISTOL, 256);
        GivePlayerWeapon(playerid, SHOTGUN, 50);
        SetPlayerSkin(playerid, 282);
        SetPlayerPos(playerid, 2273.6729, 2447.4644, 3.5313);
        SetPlayerFacingAngle(playerid, 182.2979);
        PlayerClass[playerid] = 5;
    }

    return 1;
}
This command only runs the first if statement. If you try to switch from any class to any other class, it switches your class only to taxi.
Reply


Messages In This Thread
What's wrong with this command? - by austin070 - 26.01.2014, 15:30
Re: What's wrong with this command? - by Sawalha - 26.01.2014, 15:42
Re : What's wrong with this command? - by MCZOFT - 26.01.2014, 15:44
Re: What's wrong with this command? - by Konstantinos - 26.01.2014, 15:45
Re: Re : What's wrong with this command? - by austin070 - 26.01.2014, 15:47
Re: What's wrong with this command? - by austin070 - 26.01.2014, 15:53

Forum Jump:


Users browsing this thread: 1 Guest(s)