29.05.2014, 11:46
So I've had this room with poison for as long as I can remember, and if you're in it you will loose 1 health every second..
This under OnGameModeInit, pretty basic really.
The check was the following:
Also very basic, however it is this function that screwed it up
I've searched my script for a while to figure out what was wrong since I lost 1 health all the time even if I was not in the zone, when I noticed that I had the max_x coordinates in min_y and the min_y coordinates in max_x.
The correct function for my script was
Since I copypasted this version from another script where it used a similar version and my poison script had been working good until I changed the function.
This resulted in taking 1 damage every second in the following zone: http://i.imgur.com/ht6xtSl.png
Instead of the very small zone in the top-left corner: http://i.imgur.com/SnkIUiT.png
Notice any difference? http://i.imgur.com/PwsJuyw.gif
After fixing this error I really felt like the beginner I was when I started scripting, and that this was a scripting fail.
Anyways, back on topic, what scripting fails have you done? Has anything made you feel like a beginner when you're a great scripter? Have you ever made a really basic error and not figured it out? Post it all!
pawn Code:
SetTimer("PoisonCheck", 1000, true);
The check was the following:
pawn Code:
forward PoisonCheck();
public PoisonCheck()
{
foreach(new i:Player)
{
if(IsPlayerInArea(i, -2692.4241, -2676.4875, 657.7609, 665.1196))
{
new Float:Health;
GetPlayerHealth(i, Health);
SetPlayerHealth(i, Health-1);
}
}
}
pawn Code:
stock IsPlayerInArea(playerid, Float:min_x, Float:min_y, Float:max_x, Float:max_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= min_x && Y >= min_y && X <= max_x && Y <= max_y) return 1;
return 0;
}
The correct function for my script was
pawn Code:
stock IsPlayerInArea(playerid, Float:min_x, Float:max_x, Float:min_y, Float:max_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= min_x && Y >= min_y && X <= max_x && Y <= max_y) return 1;
return 0;
}
This resulted in taking 1 damage every second in the following zone: http://i.imgur.com/ht6xtSl.png
Instead of the very small zone in the top-left corner: http://i.imgur.com/SnkIUiT.png
Notice any difference? http://i.imgur.com/PwsJuyw.gif
After fixing this error I really felt like the beginner I was when I started scripting, and that this was a scripting fail.
Anyways, back on topic, what scripting fails have you done? Has anything made you feel like a beginner when you're a great scripter? Have you ever made a really basic error and not figured it out? Post it all!