SAMPHP provides an API for developing SA:MP Gamemodes using the popular script language PHP.
Nearly every native function and every callback known from SA:MP are implemented. Most functions have the exact same syntax as their PAWN counterpart. Every function, that uses reference-passing got changed and either returns an associated array containing the information or if it only returns one information, returns it directly.
PAWN Example
public OnPlayerConnect(playerid)
{
//Get the name of the player that connected and display a join message to other players
new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has joined the server.", name);
SendClientMessageToAll(0xC4C4C4FF, string);
return 1;
}
Same code with SAMPHP
function OnPlayerConnect($playerid)
{
//Get the name of the player that connected and display a join message to other players
$playername = GetPlayerName($playerid);
SendClientMessageToAll(0xC4C4C4FF, "$playername has joined the server.");
return true;
}
We also created a very cool framework for SAMPHP, making it even more easier to write short and beautiful code. The code above might look like the following:
Event::on('PlayerConnect', function($player)
{
SendClientMessageToAll(0xC4C4C4FF, $player->getName()." has joined the server.");
return true;
});
It's easy to create commands too! The code below should show how easy it is to create a command:
Command::register("name", function($player, $params) {
$player->sendClientMessage(0xFF9900, "Your Player name is: ".$player->getName()."!");
});
CMD::register("info", function($player, $params) {
$player->sendClientMessage(0xFF9900, "Your name is ".$player->getName().", and you're connect to our server");
$player->sendClientMessage(0xFF9900, "with the player id ".$player->id."!";
});
Please look here for installation instructions: http://forum.sa-mp.com/showthread.php?t=442302