SA-MP Forums Archive
Change Name When AFK? - 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: Change Name When AFK? (/showthread.php?tid=276793)



Change Name When AFK? - lyrics - 15.08.2011

Hey hey hey i saw some server using AFK System
But. it setting the name to PlayerName[AFK]

How to do that?

I fail at scripting about cool stuff!


Re: Change Name When AFK? - [L3th4l] - 15.08.2011

pawn Код:
new iName[MAX_PLAYER_NAME], iName2[MAX_PLAYER_NAME + 5];
GetPlayerName(playerid, iName, sizeof(iName));

format(iName2, sizeof(iName2), "%s[AFK]", iName);
SetPlayerName(playerid, iName2);



Re: Change Name When AFK? - lyrics - 15.08.2011

How can i set the name back when its /back


Re: Change Name When AFK? - lyrics - 15.08.2011

it gives me 2 errors

Код:
H:\GTA San Andreas\SAMP Server\gamemodes\XtremeKakashiV2.pwn(1082) : warning 219: local variable "iName" shadows a variable at a preceding level
H:\GTA San Andreas\SAMP Server\gamemodes\XtremeKakashiV2.pwn(1104) : warning 219: local variable "iName" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: Change Name When AFK? - lyrics - 15.08.2011

Help pls!


Re: Change Name When AFK? - Lorenc_ - 15.08.2011

Store the player name in a variable:

pawn Код:
new l_AfkName[MAX_PLAYERS][MAX_PLAYER_NAME];
pawn Код:
new iName[MAX_PLAYER_NAME], iName2[MAX_PLAYER_NAME + 5];
GetPlayerName(playerid, iName, sizeof(iName));

format(l_AfkName[playerid], 24, "%s", iName);

format(iName2, sizeof(iName2), "%s[AFK]", iName);
SetPlayerName(playerid, iName2);
pawn Код:
SetPlayerBackToName(playerid)
{
    SetPlayerName(playerid, l_AfkName[playerid]);
}



Re: Change Name When AFK? - Basicz - 15.08.2011

pawn Код:
new
    tempName[ MAX_PLAYERS ][ 24 ],
    oldName[ MAX_PLAYERS ][ 24 ]
;

CMD:afk( playerid, params[ ] )
{
    // .............

    GetPlayerName( playerid, oldName[ playerid ], 24 );
    format( tempName[ playerid ], 24, "%s[AFK]", oldName[ playerid ] );
    SetPlayerName( playerid, tempName[ playerid ] );
}

CMD:back( playerid, params[ ] )
{
    // .....................

    SetPlayerName( playerid, oldName[ playerid ] );

    return 1;
}

// example with zcmd



Re: Change Name When AFK? - i514x - 15.08.2011

//Top of the script
new OldName[MAX_PLAYERS][MAX_PLAYER_NAME];

//Command /afk
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, OldName[playerid], MAX_PLAYER_NAME);
format(string, sizeof(string), "%s[AFK]", OldName[playerid]);
SetPlayerName(playerid, string);

//Command /back
SetPlayerName(playerid, OldName[playerid]);

//edit: haha 3 replies nearly at once


Re: Change Name When AFK? - lyrics - 15.08.2011

1 Error


Код:
H:\GTA San Andreas\SAMP Server\gamemodes\XtremeKakashiV2.pwn(1099) : error 021: symbol already defined: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: Change Name When AFK? - lyrics - 15.08.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
pawn Код:
new
    tempName[ MAX_PLAYERS ][ 24 ],
    oldName[ MAX_PLAYERS ][ 24 ]
;

CMD:afk( playerid, params[ ] )
{
    // .............

    GetPlayerName( playerid, oldName[ playerid ], 24 );
    format( tempName[ playerid ], 24, "%s[AFK]", oldName[ playerid ] );
    SetPlayerName( playerid, tempName[ playerid ] );
}

CMD:back( playerid, params[ ] )
{
    // .....................

    SetPlayerName( playerid, oldName[ playerid ] );

    return 1;
}

// example with zcmd
Thanks dude it work!