I dont get any idea, what to do? - 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: I dont get any idea, what to do? (
/showthread.php?tid=453761)
I dont get any idea, what to do? -
ACI - 26.07.2013
Hello. I've made a Player Kill FS, what it does that if a player is killed in a roleplay, he gets kicked and his name is saved in the log. Now, OnPlayerConnect(), if the player comes with a name which is killed, it must kick him, but it doesn't work. It saves the name in the log, but it doesn't kick if someone comes with the name which is killed [the name in the log]. What to do?
CODE:
pawn Код:
public OnPlayerConnect(playerid)
{
new Gpd[MAX_PLAYER_NAME];
GetPlayerName(playerid, Gpd, sizeof Gpd);
fopen("PK_list.txt", io_read);
if(fexist("PK_list.txt"))
{
fread(PK_Log, Gpd, sizeof Gpd);
if(strcmp(Gpd,Gpd,true))
{
Kick(playerid);
}
}
return 1;
}
Re: I dont get any idea, what to do? -
Threshold - 26.07.2013
pawn Код:
public OnPlayerConnect(playerid)
{
new Gpd[MAX_PLAYER_NAME];
GetPlayerName(playerid, Gpd, sizeof(Gpd));
new File:killfile = fopen("PK_list.txt", io_read);
if(fexist("PK_list.txt"))
{
new string[25];
while(fread(killfile, string))
{
if(strcmp(Gpd, string, true) == 0)
{
Kick(playerid);
}
}
}
return 1;
}
You need to read line by line in this file, so you must use:
pawn Код:
while(fread(filename, stringtosaveto))
{
if(strcmp(stringtofind, stringtosaveto, ignorecase) == 0)
{
//etc.
}
}
As explained in:
https://sampwiki.blast.hk/wiki/Fread
Respuesta: I dont get any idea, what to do? -
Xabi - 26.07.2013
pawn Код:
public OnPlayerConnect(playerid)
{
new Gpd[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
new File:PK_Log = fopen("PK_list.txt", io_read);
if(fexist("PK_list.txt"))
{
while(fread(PK_Log, Gpd)
{
if(strcmp(Gpd,PlayerName,true)==0)
{
Kick(playerid);
}
}
}
return 1;
}
Try this.