Code
public OnPlayerCommandText(playerid, cmdtext [])
{
if(PlayerToPoint(2, playerid, 404.84,2535.26,16.54)
{
if(strcmp("/wpm4", cmdtext, true) == 0)
{
if(GetPlayerMoney(playerid) >= 1200)
{
GivePlayerWeapon(playerid, 31, 500);
GivePlayerMoney(playerid, -1200);
SendClientMessage(playerid, COLOR_YLW, "M4 für 1200$ gekauft.");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Du hast zuwenig Geld für eine M4!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Du musst in dem Pickup stehen!");
}
return 1;
}
Alles anzeigen
Und die Funktion PlayertoPoint:
Code
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if (IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
Alles anzeigen