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



CMD help - ALoX12 - 12.07.2015

PHP код:
CMD:tie(playeridparams[])
{
       new 
targetid;
       new 
current_zone;
       
current_zone Player_Zone[targetid];
       new 
vehicle;
       
vehicle GetPlayerVehicleID(playerid);
       if(
sscanf(params"u"targetid)) return SendClientMessage(playeridRED"[USAGE]: /tie [name/id]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridRED"Player not found.");
       if(
GetTeam{playerid} != CLASS_CIV) return SendClientMessage(playeridRED"Only civilians can use this command.");
       if(
GetTeam{targetid} == CLASS_MEDIC) return SendClientMessage(playeridRED"You cant kidnap medics.");
       if(
targetid == playerid) return SendClientMessage(playeridRED"You cant kidnap yourself");
       if(!
ProxDetectorS(5.0playeridtargetid)) return SendClientMessage(playeridRED"That player is not close enough.");
       if(!
IsPlayerInAnyVehicle(targetid) && !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridRED"You both have to be in a vehicle.");
       if(
PlayerInfo[playerid][pRope] < 1) return SendClientMessage(playeridRED"You need rope to kidnap players.");
       if(
HasBeenTied{targetid} == true) return SendClientMessage(playeridRED"That player is already tied up.");
       if(!
IsPlayerInVehicle(targetidvehicle)) return SendClientMessage(playeridRED"You both have to be in the same vehicle.");
       if(
GetPlayerState(targetid) == PLAYER_STATE_DRIVER) return SendClientMessage(playeridRED"You cant kidnap the driver.");
    if(
IsOnduty{targetid} == 1) return SendClientMessage(playeridRED"You cant kidnap On-Duty admins.");
    if(
IsAtEvent{targetid} == 1) return SendClientMessage(playeridRED"You cant kidnap players at events.");
    if(
IsAtEvent{targetid} == 0)
    {
        
TogglePlayerControllable(targetidfalse);
          
HasBeenTied{targetid} = true;
           
PlayerInfo[playerid][pCrimes] ++;
           
PlayerInfo[playerid][pRope] --;
           
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
format(fstrsizeof(fstr), "%s [%d] has just kidnapped you."GetName(playerid), playerid);
           
SendClientMessage(targetidREDfstr);
           
GameTextForPlayer(targetid"~r~Kidnapped"30005);
           
GameTextForPlayer(playerid"~g~Player Tied Up"30005);
           
SendClientMessage(playeridYELLOW"You have successfully tied the player up.");
           
SendClientMessage(playeridRED"Kidnap [WANTED LEVEL INCREASED]");
           
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s [%d] has just kidnapped %s [%d] at %s."GetName(playerid), playeridGetName(targetid), targetidZoneNames[current_zone][zone_name]);
           
CopRadio(BLUEfstr);
    }
    else
    {
        
SendClientMessage(playeridRED"You cant kidnap players at events.");
    }
       new 
astring[64];
       
format(astringsizeof(astring),"%s [%d] typed: /tie %d"GetName(playerid), playeridtargetid);
       
SendAdminMessage(GREYastring);
    return 
true;

How can i add if player is kidnapped so it should take target cash and give it player in every 1 in game minute. like 20 percentage cash from target cash and give it to playerid


Re: CMD help - IceBilizard - 12.07.2015

You can use Timer let me give you a simple example

pawn Код:
new TTime[MAX_PLAYERS]; //On TOp of script

CMD:tie(playerid, params[])
{
       new targetid;
       new current_zone;
       current_zone = Player_Zone[targetid];
       new vehicle;
       vehicle = GetPlayerVehicleID(playerid);
       if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, RED, "[USAGE]: /tie [name/id]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, RED, "Player not found.");
       if(GetTeam{playerid} != CLASS_CIV) return SendClientMessage(playerid, RED, "Only civilians can use this command.");
       if(GetTeam{targetid} == CLASS_MEDIC) return SendClientMessage(playerid, RED, "You cant kidnap medics.");
       if(targetid == playerid) return SendClientMessage(playerid, RED, "You cant kidnap yourself");
       if(!ProxDetectorS(5.0, playerid, targetid)) return SendClientMessage(playerid, RED, "That player is not close enough.");
       if(!IsPlayerInAnyVehicle(targetid) && !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You both have to be in a vehicle.");
       if(PlayerInfo[playerid][pRope] < 1) return SendClientMessage(playerid, RED, "You need rope to kidnap players.");
       if(HasBeenTied{targetid} == true) return SendClientMessage(playerid, RED, "That player is already tied up.");
       if(!IsPlayerInVehicle(targetid, vehicle)) return SendClientMessage(playerid, RED, "You both have to be in the same vehicle.");
       if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, RED, "You cant kidnap the driver.");
    if(IsOnduty{targetid} == 1) return SendClientMessage(playerid, RED, "You cant kidnap On-Duty admins.");
    if(IsAtEvent{targetid} == 1) return SendClientMessage(playerid, RED, "You cant kidnap players at events.");
    if(IsAtEvent{targetid} == 0)
    {
        TogglePlayerControllable(targetid, false);
           HasBeenTied{targetid} = true;
           PlayerInfo[playerid][pCrimes] ++;
           PlayerInfo[playerid][pRope] --;
           SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
           format(fstr, sizeof(fstr), "%s [%d] has just kidnapped you.", GetName(playerid), playerid);
           SendClientMessage(targetid, RED, fstr);
           GameTextForPlayer(targetid, "~r~Kidnapped", 3000, 5);
           GameTextForPlayer(playerid, "~g~Player Tied Up", 3000, 5);
           SendClientMessage(playerid, YELLOW, "You have successfully tied the player up.");
           SendClientMessage(playerid, RED, "Kidnap [WANTED LEVEL INCREASED]");
           format(fstr, sizeof(fstr), "[DISPATCH]: Suspect %s [%d] has just kidnapped %s [%d] at %s.", GetName(playerid), playerid, GetName(targetid), targetid, ZoneNames[current_zone][zone_name]);
           TTime[targetid] = SetTimerEx("TieTimer", 120000, 1 ,"i", targetid);//new thing Added
           CopRadio(BLUE, fstr);
    }
    else
    {
        SendClientMessage(playerid, RED, "You cant kidnap players at events.");
    }
       new astring[64];
       format(astring, sizeof(astring),"%s [%d] typed: /tie %d", GetName(playerid), playerid, targetid);
       SendAdminMessage(GREY, astring);
    return true;
}

forward TieTimer(playerid);
public TieTimer(playerid)
{
    if(HasBeenTied{playerid} == true)
    {
        //Do stuff here
    }
    return 1;
}
Note: You must kill timer when player get released from kidnapper with KillTimer(TTime[playerid or targetid]);


Re : CMD help - KillerDVX - 12.07.2015

Try this :

PHP код:
CMD:tie(playeridparams[])
{
       new 
targetid;
       new 
current_zone;
       
current_zone Player_Zone[targetid];
       new 
vehicle;
       
vehicle GetPlayerVehicleID(playerid);
       if(
sscanf(params"u"targetid)) return SendClientMessage(playeridRED"[USAGE]: /tie [name/id]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridRED"Player not found.");
       if(
GetTeam{playerid} != CLASS_CIV) return SendClientMessage(playeridRED"Only civilians can use this command.");
       if(
GetTeam{targetid} == CLASS_MEDIC) return SendClientMessage(playeridRED"You cant kidnap medics.");
       if(
targetid == playerid) return SendClientMessage(playeridRED"You cant kidnap yourself");
       if(!
ProxDetectorS(5.0playeridtargetid)) return SendClientMessage(playeridRED"That player is not close enough.");
       if(!
IsPlayerInAnyVehicle(targetid) && !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridRED"You both have to be in a vehicle.");
       if(
PlayerInfo[playerid][pRope] < 1re[/CENTER]turn SendClientMessage(playeridRED"You need rope to kidnap players.");
       if(
HasBeenTied{targetid} == true) return SendClientMessage(playeridRED"That player is already tied up.");
       if(!
IsPlayerInVehicle(targetidvehicle)) return SendClientMessage(playeridRED"You both have to be in the same vehicle.");
       if(
GetPlayerState(targetid) == PLAYER_STATE_DRIVER) return SendClientMessage(playeridRED"You cant kidnap the driver.");
    if(
IsOnduty{targetid} == 1) return SendClientMessage(playeridRED"You cant kidnap On-Duty admins.");
    if(
IsAtEvent{targetid} == 1) return SendClientMessage(playeridRED"You cant kidnap players at events.");
    if(
IsAtEvent{targetid} == 0)
    {
           
TogglePlayerControllable(targetidfalse);
           
HasBeenTied{targetid} = true;
           
PlayerInfo[playerid][pCrimes] ++;
           
PlayerInfo[playerid][pRope] --;
           
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
           
format(fstrsizeof(fstr), "%s [%d] has just kidnapped you."GetName(playerid), playerid);
           
SendClientMessage(targetidREDfstr);
           
GameTextForPlayer(targetid"~r~Kidnapped"30005);
           
GameTextForPlayer(playerid"~g~Player Tied Up"30005);
           
SendClientMessage(playeridYELLOW"You have successfully tied the player up.");
           
SendClientMessage(playeridRED"Kidnap [WANTED LEVEL INCREASED]");
           
format(fstrsizeof(fstr), "[DISPATCH]: Suspect %s [%d] has just kidnapped %s [%d] at %s."GetName(playerid), playeridGetName(targetid), targetidZoneNames[current_zone][zone_name]);
           
SetTimerEx("TakeMoney",60000,false,"i",playerid);
           
CopRadio(BLUEfstr);
    }
    else
    {
        
SendClientMessage(playeridRED"You cant kidnap players at events.");
    }
       new 
astring[64];
       
format(astringsizeof(astring),"%s [%d] typed: /tie %d"GetName(playerid), playeridtargetid);
       
SendAdminMessage(GREYastring);
    return 
true;
}
forward TakeMoney(playerid);
public 
TakeMoney(playerid)
{
    new 
targetid;
    new 
mrand =random(GetPlayerMoney(targetid));
    
GivePlayerMoney(playerid,mrand);
    
GivePlayerMoney(ID,-mrand);
    return 
1;




Re: CMD help - Roberto80 - 12.07.2015

how you use " if(HasBeenTied{targetid} == true) "
{targetid} ? its [targetid] and same for "if(IsOnduty{targetid} == 1) || if(IsAtEvent{targetid} == 1) "