/Drag command.
#1

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,
Reply
#2

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.
Reply
#3

Awesome thanks for that much appreciated. Reped.

Rhys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)