SA-MP Forums Archive
Kicking for no reason - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Kicking for no reason (/showthread.php?tid=287698)



Kicking for no reason - [GOD]Dragonster82 - 04.10.2011

pawn Код:
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,Servt);
    SetPlayerWorldBounds(playerid, 2907.791, 175.1681, -910.8743, -2791.012);
    new skink;
    skink=GetPlayerSkin(playerid);
    if(skink==280||skink==286||skink==285||skink==165) {
        SetPlayerTeam(playerid,0);
        PoliceRank[playerid] = 1;
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome To Team: Police");
        GameTextForPlayer(playerid,"~bl~Police",3000,3);
        PoliceRank[playerid] = 1;                 // Sets the guy's rank to 1, by default for now.
        SetPlayerColor(playerid,COLOR_BLUE);
    }
    if(skink==248||skink==104||skink==107||skink==120) {
        SetPlayerTeam(playerid,1);
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome To Team :Gangs");
        GameTextForPlayer(playerid,"~r~Gangs",3000,3);
        GangRank[playerid] = 1;                   // Sets the guy's rank to 1, by default for now.
        SetPlayerColor(playerid,COLOR_ORANGE);
    }
    if(skink==270) {
        new pName[MAX_PLAYER_NAME];               // Check if it is darren
        GetPlayerName(playerid,pName,sizeof(pName));
        if(strcmp(pName,"[DCV]Dragon") == 0) {    //String compare between the users name and the selected name.
            new string[128];
            format(string,sizeof(string),"Welcome back Darren, the leader of Gangs.");
            SetPlayerTeam(playerid, 1);           // HAIL THE DARREN / DRAGON
            GangRank[playerid] = 1337;
            SetPlayerColor(playerid, COLOR_PURPLE);
            SendClientMessage(playerid,COLOR_PURPLE,string);
        }
    }
    SendClientMessage(playerid,COLOR_BRIGHTRED,"Sorry! You are not darren or notis!");
    Kick(playerid);
    if(skink==164) {
        new pName2[MAX_PLAYER_NAME];              // Check if it is notis
// Getting the players name and storing it in pName
        GetPlayerName(playerid, pName2, sizeof(pName2));
//checks if it is notis too.
        if(strcmp(pName2,"[DCV]Notis") == 0) {
            new string2[128];
            format(string2,sizeof(string2),"Welcome back Notis, the leader of Police.");
            SetPlayerTeam(playerid, 0);
            PoliceRank[playerid] = 1337;
            SetPlayerColor(playerid, COLOR_YELLOW);
            SendClientMessage(playerid,COLOR_WHITE,string2);
        }
    }
    SendClientMessage(playerid,COLOR_BRIGHTRED,"Sorry! You are not darren or notis!");
    Kick(playerid);
    return 1;
}

Although i have the name required, and stuff, however....

IT KICKS ME!!


Re: Kicking for no reason - Vince - 04.10.2011

You've got to understand the code flow. It will check all of the 3 if-statements and execute any or all of them if the statement is true. Then the code reaches your Kick() statement and executes it every time, regardless of whether any of the preceding if-clauses were true. What you're looking for is possibly an if-elseif-else clause or a switch statement.

I suggest you read this thoroughly: https://sampwiki.blast.hk/wiki/Control_Structures


Re: Kicking for no reason - [GOD]Dragonster82 - 04.10.2011

I've read it already, but... I can't seem to get else if to work :\


Re: Kicking for no reason - Zonoya - 04.10.2011

lol it kicks u if ur not Darren or notis maybe that is why?


Re: Kicking for no reason - $India$ - 04.10.2011

pawn Код:
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,Servt);
    SetPlayerWorldBounds(playerid, 2907.791, 175.1681, -910.8743, -2791.012);
    new skink;
    skink=GetPlayerSkin(playerid);
    if(skink==280||skink==286||skink==285||skink==165) {
        SetPlayerTeam(playerid,0);
        PoliceRank[playerid] = 1;
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome To Team: Police");
        GameTextForPlayer(playerid,"~bl~Police",3000,3);
        PoliceRank[playerid] = 1;                 // Sets the guy's rank to 1, by default for now.
        SetPlayerColor(playerid,COLOR_BLUE);
    }
    if(skink==248||skink==104||skink==107||skink==120) {
        SetPlayerTeam(playerid,1);
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Welcome To Team :Gangs");
        GameTextForPlayer(playerid,"~r~Gangs",3000,3);
        GangRank[playerid] = 1;                   // Sets the guy's rank to 1, by default for now.
        SetPlayerColor(playerid,COLOR_ORANGE);
    }
    if(skink==270) {
        new pName[MAX_PLAYER_NAME];               // Check if it is darren
        GetPlayerName(playerid,pName,sizeof(pName));
        if(strfind(pName,"[DCV]Dragon") == 0) {    //String compare between the users name and the selected name.
            new string[128];
            format(string,sizeof(string),"Welcome back Darren, the leader of Gangs.");
            SetPlayerTeam(playerid, 1);           // HAIL THE DARREN / DRAGON
            GangRank[playerid] = 1337;
            SetPlayerColor(playerid, COLOR_PURPLE);
            SendClientMessage(playerid,COLOR_PURPLE,string);
        }
    }
    SendClientMessage(playerid,COLOR_BRIGHTRED,"Sorry! You are not darren or notis!");
    Kick(playerid);
    if(skink==164) {
        new pName2[MAX_PLAYER_NAME];              // Check if it is notis
// Getting the players name and storing it in pName
        GetPlayerName(playerid, pName2, sizeof(pName2));
//checks if it is notis too.
        if(strfind(pName2,"[DCV]Notis") == 0) {
            new string2[128];
            format(string2,sizeof(string2),"Welcome back Notis, the leader of Police.");
            SetPlayerTeam(playerid, 0);
            PoliceRank[playerid] = 1337;
            SetPlayerColor(playerid, COLOR_YELLOW);
            SendClientMessage(playerid,COLOR_WHITE,string2);
        }
    }
    SendClientMessage(playerid,COLOR_BRIGHTRED,"Sorry! You are not darren or notis!");
    Kick(playerid);
    return 1;
}