SA-MP Forums Archive
OnPlayerSpawn stopping? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerSpawn stopping? (/showthread.php?tid=173593)



OnPlayerSpawn stopping? - Sky4D - 03.09.2010

Here's the code that initiates the OnPlayerSpawn code..

public RoundControl
pawn Код:
public RoundControl()
{
    new string[128];
    if(global_RoundStarted == 0) {
        new roundType;
        roundType = minrand(1, 3);
        if(roundType == 1) {
            global_RoundType = "Free for All";
            print("[script] Round Type 'Free for All' selected.");
            format(string, sizeof(string), "hostname The Elimination Server: Free for All");
            SendRconCommand(string);
        }
        else if(roundType == 2) {
            global_RoundType = "Team Deathmatch";
            print("[script] Round Type 'Team Deathmatch' selected.");
            format(string, sizeof(string), "hostname The Elimination Server: Team Deathmatch");
            SendRconCommand(string);
        }
        KillTimer(RoundTimer);
        global_RoundStarted = 0;
        print("[script] Timer 'RoundTimer' killed.");
        RoundTimer = SetTimer("RoundControl", round_TimeLimit, 1);
        global_RoundStarted = 1;
        print("[script] Timer 'RoundTimer' started.");
    }
    else if(global_RoundStarted == 1) {
        //Code for restarting the round from a time limit being reached.
    }
    return 1;
}
public GameModeInit
pawn Код:
public OnGameModeInit()
{
    djson_GameModeInit();
    SetGameModeText("Elimination v1");
    SetTimer("ThreeSecondTimer", 3000, 1);
    for(new i = 0; i <= 299; i++)
    {
        if(IsInvalidSkin(i)) continue;
        AddPlayerClass(i, 130.8830,-68.6318,1.5781,208.4004,0,0,0,0,0,0);
    }
    RoundControl();
    return 1;
}
public OnPlayerSpawn
pawn Код:
public OnPlayerSpawn(playerid)
{
    new string[128];
    if(strcmp(global_RoundType, "Free for All")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
    }
    else if(strcmp(global_RoundType, "Team Deathmatch")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
        new RandomTeam = minrand(1, 2);
        if(RandomTeam == 1) {
            SetPVarInt(playerid, "Team", 1);
            global_TeamPlayers1++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 1!");
        }
        else if(RandomTeam == 2) {
            SetPVarInt(playerid, "Team", 2);
            global_TeamPlayers2++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 2!");
        }
    }
    return 1;
}
What's wrong? The SendClientMessage on OnPlayerSpawn is not working at all.


Re: OnPlayerSpawn stopping? - bigcomfycouch - 03.09.2010

strcmp return 0 when the strings are the same

pawn Код:
public OnPlayerSpawn(playerid)
{
    new string[128];
    if(!strcmp(global_RoundType, "Free for All")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
    }
    else if(!strcmp(global_RoundType, "Team Deathmatch")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
        new RandomTeam = minrand(1, 2);
        if(RandomTeam == 1) {
            SetPVarInt(playerid, "Team", 1);
            global_TeamPlayers1++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 1!");
        }
        else if(RandomTeam == 2) {
            SetPVarInt(playerid, "Team", 2);
            global_TeamPlayers2++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 2!");
        }
    }
    return 1;
}



Re: OnPlayerSpawn stopping? - Sky4D - 03.09.2010

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
strcmp return 0 when the strings are the same

pawn Код:
public OnPlayerSpawn(playerid)
{
    new string[128];
    if(!strcmp(global_RoundType, "Free for All")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
    }
    else if(!strcmp(global_RoundType, "Team Deathmatch")) {
        format(string, sizeof(string), "You are currently playing a %s!", global_RoundType);
        SendClientMessage(playerid, sc_Lime, string);
        new RandomTeam = minrand(1, 2);
        if(RandomTeam == 1) {
            SetPVarInt(playerid, "Team", 1);
            global_TeamPlayers1++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 1!");
        }
        else if(RandomTeam == 2) {
            SetPVarInt(playerid, "Team", 2);
            global_TeamPlayers2++;
            SendClientMessage(playerid, sc_White, "You have been randomly placed on Team 2!");
        }
    }
    return 1;
}
It's weird, I shut down the server, and restarting it manually, and it worked fine (without your fix); It seems GMXing is causing OnPlayerSpawn to not work? Weird..


Re: OnPlayerSpawn stopping? - Backwardsman97 - 03.09.2010

This happened to me once. There can be an error that will cause it to work sometimes and other times just stop right in the middle of the code. Try debugging it. Put in a series of prints to see how far it gets and to narrow down your error line. Although, maybe there's just a logic error.