04.02.2014, 03:04
Only the mistake connected to samp is that you do not send POST parameters in HTTP function, but you are using POST method and try to read POST variable in .php script.
The easier way for is to use $_GET variables.
The easier way for is to use $_GET variables.
pawn Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME+1], query_string[128];
GetPlayerName(playerid, name, sizeof(name));
format(query_string, sizeof(query_string), "twor.wz.sk/pripojenia.php?playername=%s", name);
HTTP(playerid, HTTP_GET, query_string, "", "SendJoinMessage");
return 1;
}
forward SendJoinMessage(index, response_code, data[]);
public SendJoinMessage(index, response_code, data[])
{
if(response_code == 200)
{
//PHP script executed successful.
SendClientMessageToAll(-1, data); //will print "Hi, %playername%" to all players
}
else print("Failed");
}
PHP код:
<?php
printf("Hi, %s!", $_GET["playername"]);
?>

