SA-MP Forums Archive
help - 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)
+--- Thread: help (/showthread.php?tid=607814)



help - GeneralAref - 24.05.2016

What is the problem in this code?
errors:
Код:
C:\Users\Aref\Desktop\Aref\CallOfDutyAdvancedWarfare\pawno\CODAW.pwn(193) : warning 215: expression has no effect
Код:
193=if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0))fScale+1.0;
Код:
public CheckRemoteGun(playerid){
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);
    if(Keys==KEY_FIRE){
        new Float:pos[12];
        const Float:fScale=0.0;
        GetPlayerCameraPos(playerid,pos[0],pos[1],pos[2]);
        GetPlayerCameraFrontVector(playerid,pos[3],pos[4],pos[5]);
        pos[6]=pos[0]+floatmul(pos[3],fScale);
        pos[7]=pos[1]+floatmul(pos[4],fScale);
        pos[8]=pos[2]+floatmul(pos[5],fScale);
        MapAndreas_FindZ_For2DCoord(pos[6],pos[7],pos[9]);
        for(new i=0;i<=100;i++){
            if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0))fScale=1.0;}
        pos[6]=pos[0]+floatmul(pos[3],fScale);
        pos[7]=pos[1]+floatmul(pos[4],fScale);
        pos[8]=pos[2]+floatmul(pos[5],fScale);
        if(IsValidDynamicObject(RGB[playerid]))DestroyDynamicObject(RGB[playerid]);
		RGB[playerid]=CreateDynamicObject(19300,pos[0],pos[1],pos[2],0.0,0.0,0.0);
		MoveDynamicObject(RGB[playerid],pos[6],pos[7],pos[8],300);
		CreateExplosion(pos[6],pos[7],pos[8],2,10.0);}
    return 1;}



Re: help - Amunra - 24.05.2016

So Where the Line ?


Re: help - GeneralAref - 24.05.2016

Код:
193=if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0))fScale+1.0;



Re: help - Dayrion - 24.05.2016

Uhm, try this:
PHP код:
        for(new i=0;i<=100;i++){
            if(!
IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0)){
            
fScale=1.0;}
        } 



Re: help - oMa37 - 24.05.2016

Why this?:
PHP код:
fScale+1.0 



Re: help - ratxrat - 24.05.2016

Код:
  if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0)){fScale=1.0;}
forget this "{ }" ?


Re: help - MBilal - 24.05.2016

Код:
if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
and see what you did!

Код:
if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0))
Compare these both and check what are you doing wrong.


Re: help - GeneralAref - 24.05.2016

IsPointInRangeOfPoint function.
Код:
stock IsPointInRangeOfPoint(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:range){
	x2-=x;
	y2-=y;
	z2-=z;
	return ((x2*x2)+(y2*y2)+(z2*z2))<(range*range);}



Re: help - Amunra - 24.05.2016

Quote:
Originally Posted by ratxrat
Посмотреть сообщение
Код:
  if(!IsPointInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[9],1.0)){fScale=1.0;}
forget this "{ }" ?
The } Is Closing from Loop xD .. So the { is not need again ..

Let make it short

PHP код:
public CheckRemoteGun(playerid)
{
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
Keys==KEY_FIRE)
    {
        new 
Float:pos[12];
        const 
Float:fScale=0.0;
        
GetPlayerCameraPos(playerid,pos[0],pos[1],pos[2]);
        
GetPlayerCameraFrontVector(playerid,pos[3],pos[4],pos[5]);
        
pos[6]=pos[0]+floatmul(pos[3],fScale);
        
pos[7]=pos[1]+floatmul(pos[4],fScale);
        
pos[8]=pos[2]+floatmul(pos[5],fScale);
        
MapAndreas_FindZ_For2DCoord(pos[6],pos[7],pos[8]);
        for(new 
i=0;i<=100;i++)
        {
            if(!
IsPlayerInRangeOfPoint(pos[6],pos[7],pos[8],pos[6],pos[7],pos[8],1.0))
            
fScale=1.0;
        }
        
pos[6]=pos[0]+floatmul(pos[3],fScale);
        
pos[7]=pos[1]+floatmul(pos[4],fScale);
        
pos[8]=pos[2]+floatmul(pos[5],fScale);
        if(
IsValidDynamicObject(RGB[playerid]))DestroyDynamicObject(RGB[playerid]);
        
RGB[playerid]= CreateDynamicObject(19300,pos[0],pos[1],pos[2],0.0,0.0,0.0);
        
MoveDynamicObject(RGB[playerid],pos[6],pos[7],pos[8],300);
        
CreateExplosion(pos[6],pos[7],pos[8],2,10.0);
    }
      return 
1;

Check this ^^


Re: help - GeneralAref - 24.05.2016

Quote:
Originally Posted by Amunra
Посмотреть сообщение
The } Is Closing from Loop xD .. So the { is not need again ..

Let make it short

PHP код:
public CheckRemoteGun(playerid)
{
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
Keys==KEY_FIRE)
    {
        new 
Float:pos[12];
        const 
Float:fScale=0.0;
        
GetPlayerCameraPos(playerid,pos[0],pos[1],pos[2]);
        
GetPlayerCameraFrontVector(playerid,pos[3],pos[4],pos[5]);
        
pos[6]=pos[0]+floatmul(pos[3],fScale);
        
pos[7]=pos[1]+floatmul(pos[4],fScale);
        
pos[8]=pos[2]+floatmul(pos[5],fScale);
        
MapAndreas_FindZ_For2DCoord(pos[6],pos[7],pos[9]);
        for(new 
i=0;i<=100;i++)
        {
            if(!
IsPlayerInRangeOfPoint(playerid,range 1.0,pos[6],pos[7],pos[8]))
            
fScale=1.0;
        }
        
pos[6]=pos[0]+floatmul(pos[3],fScale);
        
pos[7]=pos[1]+floatmul(pos[4],fScale);
        
pos[8]=pos[2]+floatmul(pos[5],fScale);
        if(
IsValidDynamicObject(RGB[playerid]))DestroyDynamicObject(RGB[playerid]);
        
RGB[playerid]= CreateDynamicObject(19300,pos[0],pos[1],pos[2],0.0,0.0,0.0);
        
MoveDynamicObject(RGB[playerid],pos[6],pos[7],pos[8],300);
        
CreateExplosion(pos[6],pos[7],pos[8],2,10.0);}
        return 
1;

Check this ^^
Код:
stock IsPointInRangeOfPoint(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:range){
	x2-=x;
	y2-=y;
	z2-=z;
	return ((x2*x2)+(y2*y2)+(z2*z2))<(range*range);}