Change Name When AFK?
#1

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!
Reply
#2

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);
Reply
#3

How can i set the name back when its /back
Reply
#4

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.
Reply
#5

Help pls!
Reply
#6

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]);
}
Reply
#7

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
Reply
#8

//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
Reply
#9

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.
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)