Drag command
#1

When i drag player it don't moves. http://www.bildites.lv/images/d8tcc32mu927us27942z.png

Drag System
PHP код:
// Dragging
new Drag[MAX_PLAYERS];
new 
Dragged[MAX_PLAYERS];
forward Draggingt(playerid);
public 
Draggingt(playerid)
{
    if(
GetPVarInt(playerid,"BeingDraggedBy") != playerid)
{
     
KillTimer(GetPVarInt(playerid,"DragTimer"));
     return 
1;
}
        new 
Float:fXFloat:fYFloat:fZintvw;
        
vw GetPlayerVirtualWorld(playerid);
        
int GetPlayerInterior(playerid);
        
SetPlayerVirtualWorld(playeridvw);
        
SetPlayerInterior(playeridint);
        
GetPlayerPos(playeridfX,fY,fZ);
        
GetXYInFrontOfPlayer(playeridfX,fY,1.0);
        
SetPlayerPos(playeridfX,fY,fZ);
        return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SetPVarInt(playerid"BeingDraggedBy"INVALID_PLAYER_ID);
    
SetPVarInt(playerid"DraggingPlayer"INVALID_PLAYER_ID);
Drag[playerid] = -1Dragged[playerid] = -1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    if(
GetPVarInt(playerid,"DraggingPlayer") != -1)
{
    new 
dragging GetPVarInt(playerid,"DraggingPlayer");
    
KillTimer(GetPVarInt(dragging,"DragTimer"));
    
SetPVarInt(dragging"BeingDraggedBy", -1);
    
SetPVarInt(dragging"DraggingPlayer", -1);
}
if(
GetPVarInt(playerid,"BeingDraggedBy") != -1)
{
    new 
cop GetPVarInt(playerid,"BeingDraggedBy");
    
KillTimer(GetPVarInt(playerid,"DragTimer"));
    
SetPVarInt(playerid"BeingDraggedBy", -1);
    
SetPVarInt(cop"DraggingPlayer", -1);
}
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_FIRE)
{
    if(
GetPVarInt(playerid,"DraggingPlayer") != -1)
    {
        new 
string[128];
        new 
giveplayerid GetPVarInt(playerid"DraggingPlayer");
        
SetPVarInt(playerid"DraggingPlayer", -1);
        
SetPVarInt(giveplayerid"BeingDragged", -1);
        
KillTimer(GetPVarInt(giveplayerid,"DragTimer"));
        
format(stringsizeof(string), "You have stopped dragging %s."GetPlayerNameEx(giveplayerid));
        
SendClientMessageEx(playeridCOLOR_GRAD3string);
        
format(stringsizeof(string), "* Officer %s has stopped dragging you."GetPlayerNameEx(playerid));
        
SendClientMessageEx(giveplayeridCOLOR_WHITEstring);
        
format(stringsizeof(string), "* %s stops dragging %s - letting them free."GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
        
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
}
}
CMD:drag(playeridparams[])
{
    if(!
IsACop(playerid))
        return 
SendClientMessageEx(playeridCOLOR_GREY"   You are not a LEO ! ");
    new 
string[128], giveplayerid;
    if(
sscanf(params"u"giveplayerid))
        return 
SendClientMessageEx(playeridCOLOR_GREY"USAGE: /drag [playerid]");
    
    if(!
IsPlayerConnected(giveplayerid))
        return 
1;
    if(
GetPVarInt(giveplayerid"PlayerCuffed") != 2)
        return 
SendClientMessageEx(playeridCOLOR_WHITE" The specified player is not cuffed !");
        
    if(
IsPlayerInAnyVehicle(playerid))
        return 
SendClientMessageEx(playeridCOLOR_WHITE" You must be out of the vehicle to use this command.");
        
    if(
GetPVarInt(giveplayerid"BeingDraggedBy") != INVALID_PLAYER_ID)
        return 
SendClientMessageEx(playeridCOLOR_WHITE" That player is already being dragged. ");
    new 
Float:dXFloat:dYFloat:dZ;
    
GetPlayerPos(giveplayeriddXdYdZ);
    if(!
IsPlayerInRangeOfPoint(playerid5.0dXdYdZ))
        return 
SendClientMessageEx(playeridCOLOR_GRAD2" That suspect is not near you.");
    
format(stringsizeof(string), "* %s has is now dragging you."GetPlayerNameEx(playerid));
    
SendClientMessageEx(giveplayeridCOLOR_WHITEstring);
    
format(stringsizeof(string), "* You are now dragging %s, you may move them now."GetPlayerNameEx(giveplayerid));
    
SendClientMessageEx(playeridCOLOR_WHITEstring);
    
format(stringsizeof(string), "* %s grabs ahold of %s and begins to move them."GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
    
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    
SendClientMessageEx(playeridCOLOR_WHITE"You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
    
    
SetPVarInt(giveplayerid"BeingDraggedBy"playerid);
    
SetPVarInt(playerid"DraggingPlayer"giveplayerid);
    
SetPVarInt(giveplayerid,"DragTimer"SetTimerEx("dragplayer"1000true"ii"playerid,giveplayerid));
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)