robber system
#1

hi there how do make it so like if a player is in range of anouther player they can steal there money



Edit: i whant to know how to do it (just give an example)
Reply
#2

Script Request thread? Do you want this done for you, or do you want to know how to do it. Please edit your post.
Reply
#3

That requires a PlayerToPlayer, PlayerToPoint, or PointToPoint function. On GF and PEN it's called Proxy something.
Reply
#4

............. i dont know how to use anyof them help
Reply
#5

You can learn here.
Reply
#6

ok i dont see how that helps coz i whant someone to rob anouther person so like that dont help....
Reply
#7

pawn Код:
// Put this in ya rob command
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (PlayerToPoint(5.00, playerid, x, y, z))
{
//effect
}
Reply
#8

how do i make it so when i go / rob it takes the other player money and gives it to me?
Reply
#9

*Sigh*
Reply
#10

Try this, it's just the /taze command from a RP script which I modified.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new giveplayername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];

    if(strcmp("/rob", cmdtext, true, 10) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(IsPlayerInAnyVehicle(playerid))
            {
              SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
              return 1;
            }
            new victim = GetClosestPlayer(playerid);
            if(IsPlayerConnected(victim))
            {
                if(GetDistanceBetweenPlayers(playerid,victim) < 5)
                {
                  if(IsPlayerInAnyVehicle(victim))
                  {
                    SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
                    return 1;
                  }
                  GetPlayerName(victim, giveplayername, sizeof(giveplayername));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    new randt = random(4)+1;
                    if(randt == 1)
                    {
                      format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    else
                    {
                        format(string, sizeof(string), "* You were robbed by %s.", sendername);
                        SendClientMessage(victim, COLOR_WHITE, string);
                        format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
                        GivePlayerMoney(playerid, GetPlayerMoney(victim));
                        ResetPlayerMoney(victim, 0);
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "  No-one near you!");
                      return 1;
                    }
                }
            }
        }
        return 1;
    }
    return 0;
}
EDIT:
Indentation looks bad on the forums but you can fix that yourself.
Reply
#11

ok iv got errors that i dont know how to fix



C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(22) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(22) : error 017: undefined symbol "GetClosestPlayer"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(25) : error 017: undefined symbol "GetDistanceBetweenPlayers"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(33) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(37) : error 017: undefined symbol "string"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(37) : error 017: undefined symbol "string"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(37) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(37) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#12

Try this

pawn Code:
forward GetClosestPlayer(p1); //at the top of script
forward Float:GetDistanceBetweenPlayers(p1,p2);
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
pawn Code:
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5) //pretty much anywhere aslong as it's outside other callbacks
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerPos(i, posx, posy, posz);
                tempposx = (oldposx -posx);
                tempposy = (oldposy -posy);
                tempposz = (oldposz -posz);
                if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                {
                    SendClientMessage(i, col1, string);
                }
                else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                {
                    SendClientMessage(i, col2, string);
                }
                else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                {
                    SendClientMessage(i, col3, string);
                }
                else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                {
                    SendClientMessage(i, col4, string);
                }
                else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                {
                    SendClientMessage(i, col5, string);
                }
            }
            else
            {
                SendClientMessage(i, col1, string);
            }
        }
    }
    return 1;
}
pawn Code:
public GetClosestPlayer(p1)
{
    new x,Float:dis,Float:dis2,player;
    player = -1;
    dis = 99999.99;
    for (x=0;x<MAX_PLAYERS;x++)
    {
        if(IsPlayerConnected(x))
        {
            if(x != p1)
            {
                dis2 = GetDistanceBetweenPlayers(x,p1);
                if(dis2 < dis && dis2 != -1.00)
                {
                    dis = dis2;
                    player = x;
                }
            }
        }
    }
    return player;
}
pawn Code:
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new giveplayername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new string[128];

    if(strcmp("/rob", cmdtext, true, 10) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(IsPlayerInAnyVehicle(playerid))
            {
              SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
              return 1;
            }
            new victim = GetClosestPlayer(playerid);
            if(IsPlayerConnected(victim))
            {
                if(GetDistanceBetweenPlayers(playerid,victim) < 5)
                {
                  if(IsPlayerInAnyVehicle(victim))
                  {
                    SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
                    return 1;
                  }
                  GetPlayerName(victim, giveplayername, sizeof(giveplayername));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    new randt = random(4)+1;
                    if(randt == 1)
                    {
                      format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    else
                    {
                        format(string, sizeof(string), "* You were robbed by %s.", sendername);
                        SendClientMessage(victim, COLOR_WHITE, string);
                        format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
                        GivePlayerMoney(playerid, GetPlayerMoney(victim));
                        ResetPlayerMoney(victim, 0);
              }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "  No-one near you!");
                      return 1;
                    }
                }
            }
        }
        return 1;
    }
    return 0;
}
Reply
#13

ok now i get these



C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(79) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(90) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(95) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(107) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(109) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(117) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.



1 Errors.




do i need anything besids


#include <a_samp>
Reply
#14

........
Reply
#15

The first 3 warnings and the last one:

79
90
95
117


There are too many ''spaces''. Delete some at those lines, just use other codes for example.

The error at 109 is something I think you have done. Probably you forgot '')'' or '';'' sign or something.
Reply
#16

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new giveplayername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new string[128];

    if(strcmp("/rob", cmdtext, true, 10) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(IsPlayerInAnyVehicle(playerid))
            {
              SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
              return 1;
            }
            new victim = GetClosestPlayer(playerid);
            if(IsPlayerConnected(victim))
            {
                if(GetDistanceBetweenPlayers(playerid,victim) < 5)
                {
                  if(IsPlayerInAnyVehicle(victim))
                  {
                    SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
                    return 1;
                  }
                  GetPlayerName(victim, giveplayername, sizeof(giveplayername));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    new randt = random(4)+1;
                    if(randt == 1)
                    {
                      format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    else
                    {
                        format(string, sizeof(string), "* You were robbed by %s.", sendername);
                        SendClientMessage(victim, COLOR_WHITE, string);
                        format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
                        GivePlayerMoney(playerid, GetPlayerMoney(victim));
                        ResetPlayerMoney(victim);
              }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "  No-one near you!");
                      return 1;
                    }
                }
            }
        }
        return 1;
    }
    return 0;
}
Reply
#17

nope dident work


C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(80) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(91) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(96) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(110) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\filterscripts\rob.pwn(11 : warning 217: loose indentation




line 110 = else
Reply
#18

Oh my bad, I see where I went wrong now.

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new giveplayername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new string[128];

    if(strcmp("/rob", cmdtext, true, 10) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(IsPlayerInAnyVehicle(playerid))
            {
              SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
              return 1;
            }
            new victim = GetClosestPlayer(playerid);
            if(IsPlayerConnected(victim))
            {
                if(GetDistanceBetweenPlayers(playerid,victim) < 5)
                {
                  if(IsPlayerInAnyVehicle(victim))
                  {
                    SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
                    return 1;
                  }
                  GetPlayerName(victim, giveplayername, sizeof(giveplayername));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    new randt = random(4)+1;
                    if(randt == 1)
                    {
                      format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    else
                    {
                        format(string, sizeof(string), "* You were robbed by %s.", sendername);
                        SendClientMessage(victim, COLOR_WHITE, string);
                        format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
                        GivePlayerMoney(playerid, GetPlayerMoney(victim));
                        ResetPlayerMoney(victim);
              }
                }
                else
                {
                  SendClientMessage(playerid, COLOR_GREY, "  No-one near you!");
                  return 1;
                }
            }
        }
        return 1;
    }
    return 0;
}
Reply
#19

yay cool thx for the help man


You wouldent happen to know how to make it so its on a timer so like if they go /rob they carnt do it for anouther 35 mins


thx for ur help
Reply
#20

pawn Code:
new JustRobbed[MAX_PLAYERS]; //Top of your script

forward RobWaitTimer(playerid); //Top of your script
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new giveplayername[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    new string[128];

    if(strcmp("/rob", cmdtext, true, 10) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(IsPlayerInAnyVehicle(playerid))
            {
              SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
              return 1;
            }
            new victim = GetClosestPlayer(playerid);
            if(IsPlayerConnected(victim))
            {
              if(JustRobbed[playerid] == 0)
              {
                    if(GetDistanceBetweenPlayers(playerid,victim) < 5)
                    {
                      if(IsPlayerInAnyVehicle(victim))
                      {
                        SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
                        return 1;
                      }
                      GetPlayerName(victim, giveplayername, sizeof(giveplayername));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        new randt = random(4)+1;
                        if(randt == 1)
                        {
                          format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
                            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        }
                        else
                        {
                            format(string, sizeof(string), "* You were robbed by %s.", sendername);
                            SendClientMessage(victim, COLOR_WHITE, string);
                            format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
                            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
                            GivePlayerMoney(playerid, GetPlayerMoney(victim));
                            ResetPlayerMoney(victim);
                            JustRobbed[playerid] = 1;
                            SetTimerEx("RobWaitTimer", 2100000, 0, "i", playerid);
                  }
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY, "No-one near you!");
                      return 1;
                    }
                }
                else
                {
                  SendClientMessage(playerid, COLOR_GREY, "You can only rob once every 35 minutes!");
                }
            }
        }
        return 1;
    }
    return 0;
}
pawn Code:
public RobWaitTimer(playerid)
{
    JustRobbed[playerid] = 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)