Код:
//1.1 SA:MP GPS - Global Player Search by Bombo
#include <a_samp>
#include <a_http>
#include "../include/gl_common.inc"
forward FindPlayer(index, code, data[]);
forward InsertPlayer(index, code, data[]);
new UName[]="test";
new Pass[]="test";
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Global Player Search by Bombo");
print("--------------------------------------\n");
SendClientMessageToAll(9424500, "\n--------------------------------------");
SendClientMessageToAll(9424500, "Global search by Bombo");
SendClientMessageToAll(9424500, "--------------------------------------\n");
return 1;
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
new PlayerIP[16];
new PlayerName[48];
new http_msg[256];
new str_id[8];
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
http_msg = "Playerid=";
valstr(str_id, playerid);
strcat(http_msg, str_id);
strcat(http_msg, "&CheckIP=");
strcat(http_msg, PlayerIP);
strcat(http_msg, "&Uname=");
strcat(http_msg, UName);
strcat(http_msg, "&Pwd=");
strcat(http_msg, Pass);
strcat(http_msg, "&PlayerName=");
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
strcat(http_msg, PlayerName);
HTTP(0, HTTP_POST, "botinform.com:9797", http_msg, "InsertPlayer"); //insert player in database
SendClientMessage(playerid, 9324500, "Type for search: /find nick");
return 1;
}
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, 9324500, "Type for search: /find nick");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256+1];
new idx;
cmd = strtok(cmdtext, idx);
//if(!IsPlayerAdmin(playerid)) return 0; // this is an admin only script
//command "/help"
if(strcmp(cmd, "/help", true) == 0)
{
SendClientMessage(playerid, 9324500, "/find [nick] - global search!");
return 1;
}
//command /find [nick]
if(strcmp(cmd, "/find", true) == 0)
{
new tmp[256];
new http_msg[512];
new str_id[8];
tmp = strtok(cmdtext,idx);
http_msg = "Playerid=";
valstr(str_id, playerid);
strcat(http_msg, str_id);
strcat(http_msg, "&Uname=");
strcat(http_msg, UName);
strcat(http_msg, "&Pwd=");
strcat(http_msg, Pass);
strcat(http_msg, "&Search=");
strcat(http_msg, tmp);
SendClientMessage(playerid, 9324500, "Searching...");
HTTP(0, HTTP_POST, "botinform.com:9797", http_msg, "FindPlayer");
return 1;
}
return 0;
}
public FindPlayer(index, code, data[])
{
new tmp[256];
new len,i,j,k;
new playerid;
new num[8];
// printf("%s", data);
for(i = 0; i < sizeof(num); ++i)
num[i] = '\0';
k = 0;
while(data[k] != ' ') //take playerid for answer
{
num[k] = data[k];
k++;
}
playerid = strval(num);
len = strlen(data);
for(i = k+1, j = 0; i < len; ++i)
{
tmp[j] = data[i];
if(tmp[j] == '\n' || tmp[j] == '\0')
{
tmp[j] = '\0';
if(tmp[j-1] == '\r')
tmp[j-1] = '\0';
SendClientMessage(playerid, 11240000, tmp); //answer
j = 0;
continue;
}
j++;
}
}
public InsertPlayer(index, code, data[])
{
new tmp[1024];
new len,i,j,k;
new playerid;
new num[8];
// printf("%s", data);
for(i = 0; i < sizeof(num); ++i)
num[i] = '\0';
k = 0;
while(data[k] != ' ') //take playerid for answer
{
num[k] = data[k];
k++;
}
playerid = strval(num);
for(i = k+1, j = 0; i < 6; ++i)
{
tmp[j] = data[i];
}
len = strlen(data);
for(i = k+1, j = 0; i < len; ++i)
{
tmp[j] = data[i];
if(tmp[j] == '\n' || tmp[j] == '\0')
{
tmp[j] = '\0';
SendClientMessage(playerid, 11240000, tmp); //answer
j = 0;
continue;
}
j++;
}
}
Ask me (pm) for full version.