SA-MP Forums Archive
/Drag command. - 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: /Drag command. (/showthread.php?tid=426388)



/Drag command. [Fixed] - Humprabbit - 28.03.2013

Hey guys, I'm probably being really dumb with this... but anybody who can help would be much appreciated
The problem is it doesn't drag the person at all...
Here is the code:
PHP код:
command(stopdragplayeridparams[])
{
    
#pragma unused params
    
    
new string[73], dragtimer;
    
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnectedEx(i))
        {
            
format(stringsizeof(string), "* %s has stopped dragging %s."GetName(playerid), GetName(i));
             
NearByMessage(playeridNICESKYstring);
             
KillTimer(dragtimer);
        }
    }
    
    return 
1;
}
new 
dragtimer;
command(dragplayeridparams[])
 {
    new 
idstring[128], dragtimer;
    if(
sscanf(params"u"id))
    {
        
SendClientMessage(playeridWHITE"SYNTAX: /drag [playerid]");
    }
    else
    {
        if(
Player[id][Tied] >= || Player[id][Cuffed] >= 1)
        {
            if(
GetDistanceBetweenPlayers(playeridid) < 7)
            {
            
format(stringsizeof(string), "You have started to drag %s."GetName(id));
                
SendClientMessage(playeridWHITEstring);
                
format(stringsizeof(string), "* %s grabs ahold of %s and starts dragging them."GetName(playerid), GetName(id));
                
NearByMessage(playeridNICESKYstring);
            
dragtimer SetTimerEx("drag"1000true"i"playerid);
            }
            else
            {
                
SendClientMessage(playeridWHITE"You're too far away!");
            }
        }
        else
        {
            
SendClientMessage(playeridWHITE"Your target has to be either tied or cuffed.");
        }
    }
    return 
1;
}
forward drag(playeridparams[]);
public 
drag(playeridparams[])
{
           new 
idstring[128];
        new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(id,xyz);

Cheers Rhys,


Re: /Drag command. - zxc1 - 28.03.2013

Change the following:
pawn Код:
forward drag(playerid, giveplayerid);
public drag(playerid, giverplayerid)
{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SetPlayerPos(giverplayerid,x, y, z);
}
pawn Код:
dragtimer = SetTimerEx("drag", 1000, true, "ii", playerid, id);
Plus the 'dragtimer' should not be defined each time again and again, define it somewhere at the top of your gm or something.


Re: /Drag command. - Humprabbit - 29.03.2013

Awesome thanks for that much appreciated. Reped.

Rhys