GetDistanceBetweenPlayerAndBot - 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: GetDistanceBetweenPlayerAndBot (
/showthread.php?tid=105134)
GetDistanceBetweenPlayerAndBot -
zpatecnik - 27.10.2009
Hi I am doing "script"

Iґd like something like Get Distance Between players but with one player and one bot
so,
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
if(newkeys & KEY_SUBMISSION){
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
if(!strcmp(npcname, "[BOT]Dealer", true)) //This checked the bots name
{
new playerid2 = npcname; // I think there is a problem - I dont know how do that
if(GetDistanceBetweenPlayers(playerid,playerid2) < 5){ //if distance between player and bot... // If distance between player and Bot 5...
SendClientMessage(playerid, COLOR_CERV, "Hrac neni dostatecne blizko."); //...do this....
joint[playerid] = 1; //...and this.
}
}
}
}
return 1;
}
The problem is probably in
Код:
new playerid2 = npcname;
->
Код:
error 033: array must be indexed (variable "-unknown-")
I know my English is not very good (in real is very very bad

) But I hope you can understand me so if you can help me, please help me
Re: GetDistanceBetweenPlayerAndBot -
boelie - 03.02.2010
I made something like that, you might wanna check this out;
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new weaponid;
weaponid = GetPlayerWeapon(playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerFacingPlayer(playerid,i,20.0))
{
if ((newkeys & 4) && (newkeys & 128))
{
if( (weaponid == 22)||(weaponid == 23)||(weaponid == 24)||(weaponid == 25)||(weaponid == 26)||
(weaponid == 27)||(weaponid == 28)||(weaponid == 29)||(weaponid == 30)||(weaponid == 31)||
(weaponid == 32)||(weaponid == 33))//GUNS
{
if (IsPlayerNPC(i))
{
ApplyAnimation(i,"KNIFE","knife_hit_3",4.1,0,0,0,1,0);
SendPlayerMessageToPlayer(i, playerid, "DIE!");
SendDeathMessage(playerid,i,367);
GivePlayerMoney(playerid, 1000);
}
}
}
}
have fun