[SUG] more precise scripting
#1

Hello,

here some ideas to improve sa-mp scripting in general...
I think there are still some functions and callbacks missing for precise scripting.

function:

-IsPlayerInWater(playerid) and IsVehicleInWater(vehicleid) >> self-explanatory
Would be very useful for more precise scripting!

callback:

-OnPlayerDamage(playerid, damagetype, weapon, losthp)

damagetype: a player (returns playerid) or some other things like fall off bike (returns -1 for normal damage)
weapon: (returns gunid if damagetype was a player!)
losthp: the health lost when player hurts

There might be other functions and callbacks missing maybe you know some very important one
Reply
#2

Agreed.
These callbacks would be really useful.
+1!
Reply
#3

Код:
stock IsPlayerInWater(playerid)
{
	new Float:x,Float:y,Float:pz;
	GetPlayerPos(playerid,x,y,pz);
	if (
 	(IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
  	|| (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
  	|| (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
  	|| (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf sьdwesten kleiner teich
  	|| (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
  	|| (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
  	|| (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
  	|| (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter sьdцstlich
  	|| (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool цstlich
  	|| (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
  	|| (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
  	|| (pz < 1.5)
	)
	{
		return 1;
	}
	return 0;
}
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}
Reply
#4

pawn Код:
stock IsPlayerInWater(playerid)
{
        new animlib[32], animname[32];
        GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        if(strcmp(animlib, "SWIM", true) == 0) return 1;
        return 0;
}
Reply
#5

ohh ok you re right nice code but some things are still missing
Reply
#6

@Raul_Ro, your example would return 1 at LS airport underground for example.
Reply
#7

i prefer the code from Blantas cos its a much shorter solution
Reply
#8

Yeah but you can't use the swimming animation anywhere then, or hackers can cheat the system by using that anim on ground. A native function would be much better..

OnPlayerDamage could be scripted with timers but as above, a native would be much better and probably more efficient.
Reply
#9

Quote:
Originally Posted by _Necro_
Посмотреть сообщение
Yeah but you can't use the swimming animation anywhere then, or hackers can cheat the system by using that anim on ground. A native function would be much better..

OnPlayerDamage could be scripted with timers but as above, a native would be much better and probably more efficient.
How do you think it would be scripted when its a native function?
Reply
#10

There wont be any new functions added in 0.3c but i totaly agree with this topic.
ive made a water thingy to btw;

Код:
stock IsPlayerSwimming(playerid)
{
	new animlib[32];
	new animname[32];
	GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,sizeof(animlib),animname,sizeof(animname));
	if(IsPlayerConnected(playerid))
	{
		if(GetPlayerAnimationIndex(playerid))
	    {
		 	if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"SWIM_crawl",true)){
            return 1;}
		 	if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_Breast",true)){
			return 1;}
		 	if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_Dive_Under",true)){
            return 1;}
		 	if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_Glide",true)){
			return 1;}
			if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_jumpout",true)){
            return 1;}
		 	if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_Tread",true)){
			return 1;}
			if(!strcmp(animlib,"SWIM",true) &&!strcmp(animname,"Swim_Under",true)){
            return 1;}
		}
	}
	return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)