SA-MP Forums Archive
when player disconnects, it sends the message 9999 times..., also problem with dini saving - 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: when player disconnects, it sends the message 9999 times..., also problem with dini saving (/showthread.php?tid=386967)



when player disconnects, it sends the message 9999 times..., also problem with dini saving - niels44 - 22.10.2012

hey everyone,

when someone leaves the server, then it sends the leave message like 99999 times... its bigg spam in chat.

does anyone knows wuts wrong with this?

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(!IsPlayerNPC(playerid))
    {
        new str[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(str, sizeof(str), "{00FF00}%s {FFFFFF}has Joined {00FF00}Street{FF0000}Rodz {0000FF}Racers", pName);
        switch (reason)
        {
            case 0:
                format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Timeout/Crash)", pName, playerid);
            case 1:
                format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Leaving)", pName, playerid);
            case 2:
                format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Kicked/Banned)", pName, playerid);
        }
        SendClientMessageToAll(COLOR_WHITE, str);
        printf("player disconnected");
        Kick(MyBot(playerid));
        new file[300];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(file,sizeof(file),"nAdmin/Users/%s.ini",name);
        if(logged[playerid] == 1)
        {
            dini_IntSet(file, "Score", PlayerInfo[playerid][score]);
            dini_IntSet(file, "Money", PlayerInfo[playerid][cash]);
            dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
            dini_IntSet(file, "CurrentVehicle", PlayerInfo[playerid][currentcar]);
            dini_IntSet(file, "HasGarage", PlayerInfo[playerid][HasGarage]);
            dini_IntSet(file, "PlayerFinished", PlayerInfo[playerid][PlayerFinished]);
            dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
            dini_IntSet(file, "Banned", PlayerInfo[playerid][Banned]);
            dini_IntSet(file, "Muted", PlayerInfo[playerid][Muted]);
        }
        logged[playerid] = 0;
    }
    return 1;
}
greets niels

EDIT:

i also have a problem when i wanna save the admin level/vip level to a players file, it doesnt sets it somehow... and i know dini isnt used much anymore, but i like it and could someone help me with it?

pawn Код:
CMD:setlevel(playerid, params[])
{
    new level, aname[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be a RCON Admin to use this command!");
    new targetid;
    if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
    if(level < 1 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 1 To 10");
    new string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
    PlayerInfo[targetid][AdminLevel]=level;
    GetPlayerName(playerid, tname, sizeof(tname));
    format(file,sizeof(file),"nAdmin/Users/%s.ini",targetid);
    dini_IntSet(file,"AdminLevel",level);
    GetPlayerName(playerid, aname, sizeof(aname));
    format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
    SendClientMessage(targetid, COLOR_GREEN, string1);
    GameTextForPlayer(targetid, "Promoted!", 2000, 5);
    format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
    SendClientMessageToAll(COLOR_YELLOW, string2);
    return 1;
}
CMD:setvip(playerid, params[])
{
    new level, aname[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be a RCON Admin to use this command!");
    new targetid;
    if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setvip [PlayerID][Level]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
    if(level < 1 || level > 3) return SendClientMessage(playerid, COLOR_RED, "VIP Level Range Is From 1 To 3");
    new string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
    PlayerInfo[targetid][VipLevel] = level;
    GetPlayerName(playerid, tname, sizeof(tname));
    format(file,sizeof(file),"nAdmin/Users/%s.ini",targetid);
    dini_IntSet(file,"VipLevel",level);
    GetPlayerName(playerid, aname, sizeof(aname));
    format(string1, sizeof(string1), "Admin %s has set your VIP level to %i", aname, level);
    SendClientMessage(targetid, COLOR_GREEN, string1);
    GameTextForPlayer(targetid, "Congratulations!", 2000, 5);
    format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's VIP level to %i", aname, tname, level);
    SendClientMessageToAll(COLOR_YELLOW, string2);
    return 1;
}
that are my /setvip and /setlevel cmd

and its bit weird, cuz when i do that at the playerdisconnect, then it DOES saves it...


Re: when player disconnects, it sends the message 9999 times... - HyDrAtIc - 22.10.2012

Try:

Код:
public OnPlayerDisconnect(playerid, reason)
{
	if(!IsPlayerNPC(playerid))
	{
	    new str[128], pName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName, sizeof(pName));
		format(str, sizeof(str), "{00FF00}%s {FFFFFF}has Joined {00FF00}Street{FF0000}Rodz {0000FF}Racers", pName);
		switch(reason)
		{
			case 0:
				format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Timeout/Crash)", pName, playerid);
			case 1:
				format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Leaving)", pName, playerid);
			case 2:
				format(str, sizeof(str), "{00FF00}%s(ID: %d) {FFFFFF}has Left {00FF00}Street{FF0000}Rodz {0000FF}Racers {FFFFFF}(Kicked/Banned)", pName, playerid);
		}
		SendClientMessageToAll(COLOR_WHITE, str);
		printf("player disconnected");
		Kick(MyBot(playerid));
		new file[300];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		format(file,sizeof(file),"nAdmin/Users/%s.ini",name);
	    if(logged[playerid] == 1)
	    {
	  		dini_IntSet(file, "Score", PlayerInfo[playerid][score]);
	  		dini_IntSet(file, "Money", PlayerInfo[playerid][cash]);
	  		dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
	  		dini_IntSet(file, "CurrentVehicle", PlayerInfo[playerid][currentcar]);
	  		dini_IntSet(file, "HasGarage", PlayerInfo[playerid][HasGarage]);
	  		dini_IntSet(file, "PlayerFinished", PlayerInfo[playerid][PlayerFinished]);
	  		dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
	  		dini_IntSet(file, "Banned", PlayerInfo[playerid][Banned]);
	  		dini_IntSet(file, "Muted", PlayerInfo[playerid][Muted]);
	    }
		logged[playerid] = 0;
	}
	return 1;
}



Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - niels44 - 22.10.2012

hmm gonna test it now, but what did you changed? cant find it

nops didnt works... still spamming the chat with 99999 disconnect msgs


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - nickdodd25 - 22.10.2012

hmm maybe in an include that you have it is hooking OnPlayerDisconnect and there is a loop in it or something...

What includes do you have?


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - niels44 - 22.10.2012

#include <a_samp>
#include <zcmd>
#include <Dini>
#include <dudb>
#include <sscanf2>
#include <streamer>
#include <StreetRodZ\Defines>
#include <foreach>

im pretty sure it isnt in my Defines in streetrodz folder, made it myself


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - gtakillerIV - 22.10.2012

There might be another FilterScript that has a disconnect message in it or a loop of some kind that spams.


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - niels44 - 22.10.2012

nops, checked all filterscripts that are loaded, and havent got it.... any other solutions? also how to fix that dini thingy?


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - gtakillerIV - 22.10.2012

Try this:

PHP код:
new tarname[MAX_PLAYER_NAME];
    
GetPlayerName(targetid,tarname,sizeof(tarname));
    
GetPlayerName(playeridtnamesizeof(tname));
    
format(file,sizeof(file),"nAdmin/Users/%s.ini",tarname); 
Replace yours with that one and see.

This format(file,sizeof(file),"nAdmin/Users/%s.ini",targetid); is the big mistake, why?

It's because your saying that %s = targetid which is a number and we want to save it in his user file(which is written by his name not his ID), get it?


Re: when player disconnects, it sends the message 9999 times..., also problem with dini saving - niels44 - 22.10.2012

hmm i see, imma try, thnx