#include <a_samp>
new Spike[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mspike", cmdtext, true, 10) == 0)
{
PlaceSpike(playerid); //Places a spike
SendClientMessage(playerid, 0xFF0000FF, "Spike Placed");
return 1;
}
if (strcmp("/rspike", cmdtext, true, 10) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 0, 0, 0)) return SendClientMessage(playerid, 0xFF0000FF, "You is not close to ant spikes");
{
RemoveSpike(playerid); //Remove the spike he is close to.
SendClientMessage(playerid, 0xFF0000FF, "Spike Removed");
return 1;
}
}
if (strcmp("/rallspike", cmdtext, true, 10) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
RemoveSpike(i); //Removes all spikes
SendClientMessage(playerid, 0xFF0000FF, "All spikes have been removed");
return 1;
}
}
return 0;
}
stock PlaceSpike(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
Spike[playerid] = CreateObject(1593, X, Y, Z, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1137, X, Y, Z);
}
stock RemoveSpike(playerid)
{
Spike[playerid] = DestroyObject(Spike[playerid]);
}
if(strcmp("/rspike", cmdtext, true, 7) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 0, 0, 0)) return SendClientMessage(playerid, 0xFF0000FF, "You is not close to ant spikes");
RemoveSpike(playerid); //Remove the spike he is close to.
SendClientMessage(playerid, 0xFF0000FF, "Spike Removed");
return 1;
}
Bad mistake, here it is:
Replace your rsike command with this one. pawn Code:
|
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 0, 0, 0)) return SendClientMessage(playerid, 0xFF0000FF, "You is not close to ant spikes");
You'll have to store the position of spike, and then place the stored variables under /rspike in
IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z) Btw Actually you're making a : if () return firststatement(); { just a block of code... } It's kind of equal to if () else { } but better put the else anyway if this syntax hasn't been intended as this. |
#include <a_samp>
enum SPIKE_DATA{
Float:X,Float:Y,Float:Z,ID};
new Spike[MAX_PLAYERS][SPIKE_DATA];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mspike", cmdtext, true, 10) == 0)
{
PlaceSpike(playerid); //Places a spike
SendClientMessage(playerid, 0xFF0000FF, "Spike Placed");
return 1;
}
if (strcmp("/rspike", cmdtext, true, 10) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, Spike[playerid][X], Spike[playerid][Y], Spike[playerid][Z])) return SendClientMessage(playerid, 0xFF0000FF, "You is not close to ant spikes");
else {
RemoveSpike(playerid); //Remove the spike he is close to.
SendClientMessage(playerid, 0xFF0000FF, "Spike Removed");
return 1;
}
}
if (strcmp("/rallspike", cmdtext, true, 10) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
RemoveSpike(i); //Removes all spikes
SendClientMessage(playerid, 0xFF0000FF, "All spikes have been removed");
return 1;
}
}
return 0;
}
stock PlaceSpike(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
Spike[playerid][ID] = CreateObject(1593, X, Y, Z, 0.0, 0.0, 0.0);
Spike[playerid][X]=X;Spike[playerid][Y]=Y;Spike[playerid][Z]=Z;
PlayerPlaySound(playerid, 1137, X, Y, Z);
}
stock RemoveSpike(playerid)
{
Spike[playerid][ID] = DestroyObject(Spike[playerid]);
}
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 219: local variable "Z" shadows a variable at a preceding level
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(40) : error 035: argument type mismatch (argument 2)
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(41) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(41) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(41) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(42) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(42) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(42) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(43) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(43) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(43) : warning 213: tag mismatch
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 203: symbol is never used: "Z"
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 203: symbol is never used: "Y"
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\Spike.pwn(39) : warning 203: symbol is never used: "X"
It was an example actually, but OK, I'll code it for you :
PasteBin |