ip comparator with djson? - 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: ip comparator with djson? (
/showthread.php?tid=250311)
ip comparator with djson? -
sciman001 - 22.04.2011
Hi all... i tried to makle an ip comparator so that people cant cheat by making their name someone elses name and I mean.. i could have just made a password but thats too much work for me.

Heres the code:
pawn Код:
public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYER_NAME], str[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(strlen(pname) > 12) // Will kick the player if his name is longer than 12 characters.
{
SendClientMessage(playerid, COLOR_RED, "Your name is too long, It must be 12 or less characters.");
Kick(playerid);
return 0;
}
SendClientMessage(playerid, COLOR_GREEN, "PLEASE USE /help FOR SOME SERVER INFO AND COMMANDS");
SetPlayerWorldBounds(playerid, 478.7929, -490.4708, 2183.763, 1226.177);
UsePlayerPedAnims();
SetPlayerTime(playerid, 0, 0);
format(str, sizeof(str), USERFILE, pname);
new ip[24];
GetPlayerIp(playerid, ip, sizeof(ip));
if(!fexist(str))
{
djAutocommit(false);
djCreateFile (str);
djSet(str,"player/NAME", pname);
djSetInt(str,"player/RANK", pRank[playerid]);
djSetInt(str,"player/SCORE",GetPlayerScore(playerid));
djSetInt(str,"player/CASH",GetPlayerMoney(playerid));
djSet(str,"player/IP", ip);
djCommit(str);
djAutocommit(true);
}
else
{
if(ip == dj(str, "player/IP"))
{
SetPlayerScore(playerid, djInt(str, "player/SCORE"));
pRank[playerid] = djInt(str, "player/RANK");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, djInt(str, "player/CASH"));
}
else
{
new string[128];
format(string, sizeof(string), "YOU ARENT THE REAL %s!! GTFO!", pname);
SendClientMessage(playerid, COLOR_RED, string);
Kick(playerid);
return 0;
}
}
return 1;
}
error:
pawn Код:
E:\ww7\gamemodes\WW7.pwn(158) : error 033: array must be indexed (variable "ip")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
Please tell me how to fix this!!! THX!
Re: ip comparator with djson? -
sciman001 - 22.04.2011
anybody?
Re: ip comparator with djson? -
Jefff - 22.04.2011
ip is not integer but string
pawn Код:
if(ip == dj(str, "player/IP"))
to
pawn Код:
if(!strcmp(ip, dj(str, "player/IP")))
Re: ip comparator with djson? -
sciman001 - 22.04.2011
thanks!!!