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



Code help - Biess - 30.09.2012

pawn Код:
CMD:getteam(playerid, params[])
{
   new teamid;
   if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
   if(sscanf(params,"d",teamid) return SendClientMessage(playerid, 0xFF0000FF,"USAGE: /getteam [teamid]");
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
   if(gTeam[i] == teamid)
   new player1;
   new Float:x, Float:Y, Float:Z;
   GetPlayerPos(playerid, X, Y, Z);
   SetPlayerPos(i, X+3, Y, Z);
   }
   new pname[24],dstring[124];
   GetPlayerName(playerid,pname,sizeof(pname));
   format(dstring, sizeof(dstring), "Administrator %s has teleported teamid %d ", pname, teamid);
   SendClientMessageToAll(blue, dstring);
   return 1;
}
I have that code but it gives me errors


pawn Код:
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1201) : error 001: expected token: ")", but found "return"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 017: undefined symbol "player1"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : warning 215: expression has no effect
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1207) : error 017: undefined symbol "X"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1208) : error 017: undefined symbol "X"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1206) : warning 203: symbol is never used: "x"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.



Re: Code help - newbienoob - 30.09.2012

pawn Код:
if(sscanf(params,"d",teamid)) //add 1 more ) here
new Float:X //X not x



Re: Code help - Biess - 30.09.2012

pawn Код:
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 017: undefined symbol "player1"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : warning 215: expression has no effect
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

new player1; all on that line


Re: Code help - RedJohn - 30.09.2012

Which line is 1205?


Re: Code help - Biess - 30.09.2012

new player1;


Re: Code help - RedJohn - 30.09.2012

You can delete that line because you are not using player1 anywhere.


Re: Code help - Biess - 30.09.2012

pawn Код:
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : warning 221: label name "Float" shadows tag name
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : error 017: undefined symbol "X"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : warning 215: expression has no effect
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1206) : error 017: undefined symbol "X"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1207) : error 017: undefined symbol "X"
C:\Users\Bichan\Desktop\UKTDM\gamemodes\UKTDM.pwn(1205) : warning 203: symbol is never used: "Float"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
when i delete it


Re: Code help - RedJohn - 30.09.2012

pawn Код:
CMD:getteam(playerid, params[])
{
    new teamid;
    if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
    if(sscanf(params,"d",teamid)) return SendClientMessage(playerid, 0xFF0000FF,"USAGE: /getteam [teamid]");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(gTeam[i] == teamid)
        {
            new
                player1,
                Float:X,
                Float:Y,
                Float:Z
            ;
            GetPlayerPos(playerid, X, Y, Z);
            SetPlayerPos(i, X+3, Y, Z);
        }
    }
    new pname[24],dstring[124];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(dstring, sizeof(dstring), "Administrator %s has teleported teamid %d ", pname, teamid);
    SendClientMessageToAll(blue, dstring);
    return 1;
}



Re: Code help - Biess - 30.09.2012

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
pawn Код:
CMD:getteam(playerid, params[])
{
    new teamid;
    if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
    if(sscanf(params,"d",teamid)) return SendClientMessage(playerid, 0xFF0000FF,"USAGE: /getteam [teamid]");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(gTeam[i] == teamid)
        {
            new
                player1,
                Float:X,
                Float:Y,
                Float:Z
            ;
            GetPlayerPos(playerid, X, Y, Z);
            SetPlayerPos(i, X+3, Y, Z);
        }
    }
    new pname[24],dstring[124];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(dstring, sizeof(dstring), "Administrator %s has teleported teamid %d ", pname, teamid);
    SendClientMessageToAll(blue, dstring);
    return 1;
}
Thanks works now
another question now i have to do

/getteam [ID] can you also make it

/getteam iraq /getteam england instead of ids?


pawn Код:
#define TEAM_GERMANY 0
#define TEAM_IRAQ 1
#define TEAM_ENGLAND 2
#define TEAM_USA 3
#define TEAM_NETHERLANDS 4
#define TEAM_ADMINS 5



Re: Code help - RedJohn - 30.09.2012

I don't have any experience with that so i don't know how.