CMD:setaname
#1

Hello, I'm trying to get this /setaname to work into my script.

Код:
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(3063) : error 021: symbol already defined: "OnDuty"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97460) : error 033: array must be indexed (variable "OnDuty")
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97463) : error 033: array must be indexed (variable "OnDuty")
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97474) : error 033: array must be indexed (variable "OnDuty")
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97453) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
CMD:aduty(playerid, params[])
{
    new playername[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1]; //line 97453
    GetPlayerName(playerid, playername, sizeof(playername));
    if(!PlayerInfo[playerid][pAdmin])
    {
        return SendClientMessage(playerid, -1, "You are not an admin.");
    }

    if(PlayerInfo[playerid][OnDuty]) // line 97460
    {
        SetPlayerName(playerid, PlayerInfo[playerid][pName]);
        PlayerInfo[playerid][OnDuty] = false; // 97463
        SendClientMessage(playerid,COLOR_YELLOW, "You have gone OFF administrator duty!");
    }
    else
    {
        if(!PlayerInfo[playerid][HasSetAdminName])
        {
            return SendClientMessage(playerid, -1, "You haven't set an admin name yet.");
        }
        GetPlayerName(playerid, PlayerInfo[playerid][pName], 24);
        SetPlayerName(playerid, PlayerInfo[playerid][aName]);
        PlayerInfo[playerid][OnDuty] = true; // 97474
        SendClientMessage(playerid,COLOR_YELLOW, "You have gone ON administrator duty!");
    }

    return 1;
}

CMD:setaname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        return SendClientMessage(playerid, -1, "You are not an admin.");
    }
    new adminname[24], a_string[65];
    if(sscanf(params, "s[24]", adminname))
    {
        return SendClientMessage(playerid, -1, "USAGE: /setaname [name]");
    }

    PlayerInfo[playerid][aName] = adminname;
    format(a_string, 65, "Your admin name is %s.", PlayerInfo[playerid][aName]);
    SendClientMessage(playerid, -1, a_string);
    PlayerInfo[playerid][HasSetAdminName] = true;
    return 1;
}
Reply
#2

edit, now I'm just got one error:

Код:
(97495) : error 006: must be assigned to an array
pawn Код:
PlayerInfo[playerid][pAdminName] = adminname;
Reply
#3

you've defined "OnDuty" more than one time.

Post the line number "97496"
Reply
#4

Quote:
Originally Posted by James Bob
Посмотреть сообщение
edit, now I'm just got one error:

Код:
(97495) : error 006: must be assigned to an array
pawn Код:
PlayerInfo[playerid][pAdminName] = adminname;
You need an array to store strings.
Reply
#5

How do you work with a script that has that many lines it must be really messy. I can only imagine how many times this must appear

pawn Код:
if(!PlayerInfo[playerid][pAdmin])
    {
        return SendClientMessage(playerid, -1, "You are not an admin.");
    }

How about

#define CheckAdmin(%0) !if(!PlayerInfo[%0][pAdmin]) return SendClientMessage(%0, -1, "You are not an admin.");
Now all you need to do is replace those 4 lines with CheckAdmin(playerid);

Scripts this large need to be done separated into includes with hooking I can only imagine how stupidly large some callbacks must be with a dozen systems it's no wonder your having problems.

In response to your question check this out

pawn Код:
#include <a_samp>

enum test {
    testname[MAX_PLAYER_NAME],
}
new name[MAX_PLAYERS][test];


main() {
    new tmp;
    tmp = "TestName";
    name[0][testname] = tmp;
    print(name[0][testname]);
   
}
This will fail with.....

input(11) : error 6: must be assigned to an array
Error: The compiler failed. (no error code)

This will compile

pawn Код:
#include <a_samp>

enum test {
    testname[MAX_PLAYER_NAME],
}
new name[MAX_PLAYERS][test];


main() {
    new tmp[MAX_PLAYER_NAME];
    tmp = "TestName";
    name[0][testname] = tmp;
    print(name[0][testname]);
}
This will compile

pawn Код:
#include <a_samp>

enum test {
    testname[MAX_PLAYER_NAME],
}
new name[MAX_PLAYERS][test];


main() {
    new tmp[MAX_PLAYER_NAME];
    tmp = "TestName";
    format(name[0][testname], MAX_PLAYER_NAME, "%s", tmp);
    print(name[0][testname]);
}
You can test these here

http://slice-vps.nl:7070/
Reply
#6

I've fixed all the errors, but now as soon as one of our players connect is causes the server to crash.
Код:
[08:25:29] [debug] Server crashed while executing RZRPnew.amx
[08:25:29] [debug] AMX backtrace:
[08:25:29] [debug] #0 native fread () [004057a0] from samp-server.exe
[08:25:29] [debug] #1 00026f34 in ?? (0x02d589e4) from RZRPnew.amx
[08:25:29] [debug] #2 0003d394 in public Audio_OnPlayerConnect (0x00000000) from RZRPnew.amx
[08:25:29] [debug] #3 native CallLocalFunction () [00471c30] from samp-server.exe
[08:25:29] [debug] #4 0001147c in public SSCANF_OnPlayerConnect (0x00000000) from RZRPnew.amx
[08:25:29] [debug] #5 0000b588 in public Itter_OnPlayerConnect (0x00000000) from RZRPnew.amx
[08:25:29] [debug] #6 native CallLocalFunction () [00471c30] from samp-server.exe
[08:25:29] [debug] #7 00007ca4 in public Streamer_OnPlayerConnect (0x00000000) from RZRPnew.amx
[08:25:29] [debug] #8 native CallLocalFunction () [00471c30] from samp-server.exe
[08:25:29] [debug] #9 00000ae8 in public OnPlayerConnect (0x00000000) from RZRPnew.amx
[08:25:30] [debug] Native backtrace:
[08:25:30] [debug] #0 7c90100b in RtlEnterCriticalSection () from C:\WINDOWS\system32\ntdll.dll
[08:25:30] [debug] #1 00492bd0 in ?? () from C:\Documents and Settings\Ashley\Desktop\DSRP1\samp-server.exe
pawn Код:
CMD:aduty(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, -1, "This is an admin only command!");
    if(PlayerInfo[playerid][pAdminDuty] == 0)
    {

        SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on administrative duty! Remember to check /reports!");
        SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
        PlayerInfo[playerid][pAdminDuty] = 1;
        SetPlayerHealth(playerid, 100000);
        SetPlayerArmour(playerid, 100000);
        SetPlayerColor(playerid, COLOR_TWORANGE);
        //SetPlayerSkin(playerid, 294);
        new string[128];
        format(string, sizeof(string), "Administrator %s is [ON] admin duty.", GetPlayerNameEx(playerid));
        SendClientMessageToAllEx(COLOR_GREY, string);
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_RED, "You are now off admin duty!");
        SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
        SetPlayerToTeamColor(playerid);
        //SetPlayerSkin(playerid, 299);
        PlayerInfo[playerid][pAdminDuty] = 0;
        new string[128];
        format(string, sizeof(string), "Administrator %s is [OFF] admin duty.", GetPlayerNameEx(playerid));
        SendClientMessageToAllEx(COLOR_GREY, string);
    }
    return 1;
}

CMD:setaname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        return SendClientMessage(playerid, -1, "You are not an admin.");
    }
    new adminname[24], a_string[65];
    if(sscanf(params, "s[24]", adminname))
    {
        return SendClientMessage(playerid, -1, "USAGE: /setaname [name]");
    }

    PlayerInfo[playerid][pAdminName] = strval(adminname);
    format(a_string, 65, "Your admin name is %s.", PlayerInfo[playerid][pAdminName]);
    SendClientMessage(playerid, -1, a_string);
    PlayerInfo[playerid][HasSetAdminName] = true;
    return 1;
}
Reply
#7

pawn Код:
CMD:setname(playerid, params[])
{
        if(PlayerInfo[playerid][Level] >= 4)    {
        new string[128], tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
        SetPlayerName(player1,tmp2);
        PlayerPlaySound(player1,1057,0.0,0.0,0.0);
               format(string, sizeof(string),"Admin ''%s'' Has Changed Your Name To '%s'",PlayerName2(playerid), tmp2);
        return SendClientMessage(player1,yellow,string);
    }   else return SendClientMessage(playerid,red, "ERROR: Only Level +4 can Use This Command");
}

Код HTML:
CMD:adminduty(playerid,params[])
{
   if(PlayerInfo[playerid][pAdmin])
   {
         if(PlayerInfo[playerid][pAdminDuty] == 0) {
         PlayerInfo[playerid][OnDuty] = 1;
	     new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "%s is now on Admin duty!", AdminName);
         
         
      
         SendClientMessageToAll(red, str);
         SetPlayerSkin(playerid,217);
         SetPlayerTeam(playerid, 6);
   	     SetPlayerColor(playerid, 0xF600F6FF);
         SetPlayerHealth(playerid, 100000);
         SetPlayerArmour(playerid, 100000);
		 ResetPlayerWeapons(playerid);
         GivePlayerWeapon(playerid, 38,999999999);
  
         }
         else if(PlayerInfo[playerid][pAdminDuty] == 1) {
         PlayerInfo[playerid][pAdminDuty] = 0;
         new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "%s is now off Admin duty", AdminName);
         
         SendClientMessageToAll(red, str);
         SetPlayerHealth(playerid, 0);
		 ForceClassSelection(playerid);
	     SetPlayerHealth(playerid, 0);
	     SetPlayerArmour(playerid, 0);
         new rand = random(sizeof(PlayerColors));
         SetPlayerColor(playerid, PlayerColors[rand]);
         }
   } else return 0;
   return 1;
}
Reply
#8

Quote:
Originally Posted by Alex_Obando
Посмотреть сообщение
pawn Код:
CMD:setname(playerid, params[])
{
        if(PlayerInfo[playerid][Level] >= 4)    {
        new string[128], tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
        SetPlayerName(player1,tmp2);
        PlayerPlaySound(player1,1057,0.0,0.0,0.0);
               format(string, sizeof(string),"Admin ''%s'' Has Changed Your Name To '%s'",PlayerName2(playerid), tmp2);
        return SendClientMessage(player1,yellow,string);
    }   else return SendClientMessage(playerid,red, "ERROR: Only Level +4 can Use This Command");
}

Код HTML:
CMD:adminduty(playerid,params[])
{
   if(PlayerInfo[playerid][pAdmin])
   {
         if(PlayerInfo[playerid][pAdminDuty] == 0) {
         PlayerInfo[playerid][OnDuty] = 1;
	     new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "%s is now on Admin duty!", AdminName);
         
         
      
         SendClientMessageToAll(red, str);
         SetPlayerSkin(playerid,217);
         SetPlayerTeam(playerid, 6);
   	     SetPlayerColor(playerid, 0xF600F6FF);
         SetPlayerHealth(playerid, 100000);
         SetPlayerArmour(playerid, 100000);
		 ResetPlayerWeapons(playerid);
         GivePlayerWeapon(playerid, 38,999999999);
  
         }
         else if(PlayerInfo[playerid][pAdminDuty] == 1) {
         PlayerInfo[playerid][pAdminDuty] = 0;
         new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "%s is now off Admin duty", AdminName);
         
         SendClientMessageToAll(red, str);
         SetPlayerHealth(playerid, 0);
		 ForceClassSelection(playerid);
	     SetPlayerHealth(playerid, 0);
	     SetPlayerArmour(playerid, 0);
         new rand = random(sizeof(PlayerColors));
         SetPlayerColor(playerid, PlayerColors[rand]);
         }
   } else return 0;
   return 1;
}
Код:
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(55256) : warning 219: local variable "object" shadows a variable at a preceding level
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97457) : error 033: array must be indexed (variable "OnDuty")
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97464) : error 017: undefined symbol "red"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97480) : error 017: undefined symbol "red"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97485) : error 017: undefined symbol "PlayerColors"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97485) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97485) : warning 215: expression has no effect
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97486) : error 017: undefined symbol "PlayerColors"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97486) : warning 215: expression has no effect
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97486) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97486) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRPnew.pwn(97486) : fatal error 107: too many error messages on one line

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


9 Errors.
Using your way just me errors.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)