SA-MP Forums Archive
[SOLVED]How would i do this? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]How would i do this? (/showthread.php?tid=122119)



[SOLVED]How would i do this? - JoeDaDude - 20.01.2010

How would i do this, Id like to know the correct way if you could tell me please,
Heres what ive done to give you a basic example

pawn Код:
dcmd_pick(playerid, params[])
{
    if (strlen(params))
    {
        id = strval(params);
        if (IsPlayerConnected(id))
        {
          if(gTeam[playerid] == TEAM_CROOKSF)
            {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(id, x, y, z);
            if(id == playerid)
            {
            if(gTeam[id] != gTeam[playerid])
            {
            if(GetPlayerPos(playerid) >= x, y, z)
            {
        SetTimerEx("PickTimer", 2000, 0, "i", playerid);

        GetPlayerName(id, name, sizeof(name));
        format(string, sizeof(string), "You are pickpocketing %s, Please wait 2 seconds", name);
        SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You are not a Crook");
            }
            }
            else
            {
              SendClientMessage(playerid, COLOR_RED, "You cannot use this command on yourself");
            }
            }
            else
            {
              SendClientMessage(playerid, COLOR_RED, "You cannot pickpocket a fellow crook");
            }
            }
            else
            {
              SendClientMessage(playerid, COLOR_RED, "You need to stand next to the player for 2 seconds");
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_RED, "Player not Found");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "Usage: /pick [Playerid/PartOfName]");
    }
    return 1;
}
pawn Код:
public PickTimer(playerid)
{
    if(GetPlayerPos(playerid) >= x, y, z)
    {
    GivePlayerMoney(playerid,100);
    SendClientMessage(playerid, COLOR_WHITE, "You have pickpocketed this player");
    }
    else
    {
    SendClientMessage(playerid, COLOR_WHITE, "You are not next to the player you are trying to pickpocket");
    }
}
So anyone know?


Re: How would i do this? - bobmarley137 - 20.01.2010

pawn Код:
CMD:pick(playerid, params[])
{
    new id;
    if (!sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Usage: /pick [Playerid/PartOfName]");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Player not Found");
    if (gTeam[playerid] != TEAM_CROOKSF) return SendClientMessage(playerid, COLOR_RED, "You are not a Crook");
    if (id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot use this command on yourself");\
    if (gTeam[id] == gTeam[playerid]) return SendClientMessage(playerid, COLOR_RED, "You cannot pickpocket a fellow crook");
   
    // Continue..
    new Float:x, Float:y, Float:z;
    if (GetPlayerPos(playerid, X, Y, Z) != GetPlayerPos(id, X, Y, Z)) return SendClientMessage(playerid, COLOR_RED, "You need to stand next to the player for 2 seconds");

    SetTimerEx("PickTimer", 2000, 0, "i", playerid);

    GetPlayerName(id, name, sizeof(name));
    format(string, sizeof(string), "You are pickpocketing %s, Please wait 2 seconds", name);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
}
I've also integrated zcmd+sscanf, they're much faster and easier methods. Some of this code may give you errros, I don't have time to test it, the public is also incorrect, you don't even define "x, y, z".


Re: How would i do this? - JoeDaDude - 20.01.2010

Where does that go


Re: How would i do this? - JoeDaDude - 20.01.2010

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1023) : warning 219: local variable "id" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1032) : error 017: undefined symbol "X"
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1036) : error 017: undefined symbol "name"
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1036) : error 017: undefined symbol "name"
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1036) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\sftdm.pwn(1036) : fatal error 107: too many error messages on one line

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


5 Errors.