Problems with CMD - 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: Problems with CMD (
/showthread.php?tid=81352)
Problems with CMD -
mini-d - 10.06.2009
Ive been trying to build a CMD where u can Throw a Rock at a car driver within a 50m radius I have no idea how heres my cmd so far
Код:
if (!strcmp(cmd, "/rock", true))
new rands = random(2)+1;
if(rands == 1) {
SetPlayerHealth(giveplayerid, 0);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You Just Failed);
}
return 1;
}
Re: Problems with CMD -
Burridge - 10.06.2009
Any errors with the command, when you compile?
Re: Problems with CMD -
Abernethy - 10.06.2009
Post your errors, & what lines they're on.
If you really don't mind on releasing your script. Copy your script to Pastebin.
Re: Problems with CMD -
mini-d - 10.06.2009
I dont know how to make it using all the ids with range and stuff
Re: Problems with CMD -
Joe Staff - 10.06.2009
Well it's clear you didn't leave a parameter to determine what 'giveplayerid' is. Since the idea is to quickly throw a rock at someone, perhaps you should make it decrease a players health instead of kill him/her. Also decreasing the length of the command name would be useful for on-the-fly command typing for example, "/ro <id or partofname>" would be useful. You could increase its efficiency by getting the names of nearby players so the command typing player won't have to be as precise with the player's name. For example, Bob is within 50m of the command typing player, and Bobby is 100m away from the command typing player. If you get the names of the players that are closer, the command typing player could just type "/ro b" and since the only player who's name has a 'b' in it and is within 50m of the command typing player, the rock will be thrown at Bob.
Determining if Player is close enough to a player
pawn Код:
PlayerNearPlayer(player1,player2,Float:distance)
{
new Float:tmp[2][3];
GetPlayerPos(player1,tmp[0][0],tmp[0][1],tmp[0][2]);
GetPlayerPos(player2,tmp[1][0],tmp[1][1],tmp[1][2]);
return ((((tmp[1][0]-tmp[0][0])*(tmp[1][0]-tmp[0][0]))+((tmp[1][1]-tmp[0][1])*(tmp[1][1]-tmp[0][1]))+((tmp[1][2]-tmp[0][2])*(tmp[1][2]-tmp[0][2])))<distance*distance);
}
Use DCMD or strtok to determine what the command typing player has for the 'giveplayerid'