Mask id problem
#1

hey there
i was trying to make masks system with id but the problem is that i've putted 4 random numbers (9999)
and when i put the mask on it gives player the numbers this is okay but when player speaks everytime he writes something his numbers change
i want the player to have same numbers till he quits
can you please help me with this

code
Код HTML:
new string[300];
	     new rand = random(9999)+1;
	     format(string, sizeof(string), "Stranger[%d]",rand);
		    if(PlayerTemp[playerid][hname]==1) myStrcpy(sender,string);
		    else myStrcpy(sender,RPName(playerid));
			if(text[0]== '('){
				new mid[MAX_STRING];
				strmid(mid,text,1,256,sizeof(mid));
				format(stringa,sizeof(stringa),"%s says: (( %s ))",RPName(playerid),mid);
			}
Reply
#2

You need to create the variable globally (outside any bracket).

pawn Код:
// Outside any bracket, you may aswell rename "rand" to something related to the player mask.
new rand = random(9999)+1;

// Wherever you have this code
new string[300];
format(string, sizeof(string), "Stranger[%d]",rand);
if(PlayerTemp[playerid][hname]==1) myStrcpy(sender,string);
else myStrcpy(sender,RPName(playerid));

if(text[0]== '('){
    new mid[MAX_STRING];
    strmid(mid,text,1,256,sizeof(mid));
    format(stringa,sizeof(stringa),"%s says: (( %s ))",RPName(playerid),mid);
Reply
#3

i have fixed it but
is it possible for example to use /pay [stranger id ] then it pays the amount ?
Reply
#4

pawn Код:
// Somewhere outside a bracket
new PlayerMask[MAX_PLAYERS];

// OnPlayerConnect
PlayerMask[playerid] = random(99999);

stock GetPlayerIDFromMaskID(maskid)
{    
    for(new i, j = GetPlayerPoolSize(); i <= j; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerMask[i] == maskid)
        {
            return i;
        }
    }
    return -1;
}

// /pay
new target = GetPlayerIDFromMaskID(/*id*/);
Not tested. Should work
Reply
#5

how to use it

this is cmd pay

Код:
COMMAND:pay(playerid, params[])
{
  if(PlayerTemp[playerid][hname]==1)
	{
	new asa = GetPlayerIDFromMaskID(iPlayer);
	new iPlayer, iAmount;
	new asa = GetPlayerIDFromMaskID(iPlayer);
	if( sscanf ( params, "ud", iPlayer, iAmount))  return SCP(playerid, "[PlayerID/PartOfName] [amount]");
	if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
	if(iAmount < 1 || iAmount > HandMoney(playerid)) return SendClientError(playerid, "Invalid amount specified!");
	if(PlayerInfo[playerid][pMaskID]) return SendClientError(playerid, "Invalid stranger mask");
		// if(iPlayer == playerid)	return SendClientError(playerid, "You cannot pay yourself!");
	if(iAmount > 5000000) return SendClientError(playerid, "You can pay maximum $5,000,000 at a time!");
 if(PlayerInfo[playerid][totalpayt] < 3 && iAmount > 10000 && (GetPVarInt(playerid, "PayTimer") == 0)) return SendClientError(playerid, "New players can pay $10,000 per minute!");
	if(GetDistanceBetweenPlayers(playerid, iPlayer) > 6) return SendClientError(playerid, "He is too far away!");
	if(GetTickCount() - PlayerTemp[playerid][cmdtick] < 3000) return SendClientWarning(playerid, "You may use this command only once in 3 seconds.");
	new ip1[ 24 ], ip2[ 24 ];
	GetPlayerIp(playerid, ip1, sizeof(ip1));GetPlayerIp(iPlayer, ip2, sizeof(ip2));
	SetPVarInt(playerid, "PayTimer", 0);
	SetTimerEx("PTime", 60000, false, "i", playerid);
	 if(PlayerTemp[playerid][totallogin] == 1 && iAmount > 100000) return SendClientWarning(playerid, "You may not transfer this amount of money as a new player.");
	if(!strcmp(ip1,ip2,true))
	{
		format(iStr, sizeof(iStr), "** /pay warning: %s and %s same IP (%s) - Amount: $%d", PlayerName(playerid), PlayerName(iPlayer), ip1, iAmount);
		SendClientMessageToAdmins(iStr,COLOR_HELPEROOC);
	}
	GivePlayerMoneyEx(playerid,-iAmount);GivePlayerMoneyEx(iPlayer, iAmount);
	format(iStr, sizeof(iStr), "takes out some money and hands it to %s.", MaskedName(iPlayer));
	Action(playerid, iStr);
	format(iStr, sizeof(iStr),  "[CASH]: You have given %s $%s.", MaskedName(iPlayer),AddCommasToInt(iAmount));
	SendClientMessage(playerid, COLOR_YELLOW, iStr);
	format(iStr, sizeof(iStr), "[CASH]: You have recieved $%s from %s", AddCommasToInt(iAmount),MaskedName(playerid));
	SendClientMessage(iPlayer, COLOR_YELLOW, iStr);
	format(iStr,sizeof(iStr),"14[MONEY] %s has paid $%s to %s.", PlayerName(playerid), AddCommasToInt(iAmount), PlayerName(iPlayer));
	iEcho(iStr); AppendTo(moneylog,iStr);
	}
Reply
#6

pawn Код:
COMMAND:pay(playerid, params[])
{
  if(PlayerTemp[playerid][hname]==1)
    {
    new iMask, iAmount;
        // Change "u" operator to "d" since now we're looking for an integer and not an user
    if( sscanf ( params, "dd", iMask, iAmount))  return SCP(playerid, "[PlayerID/PartOfName] [amount]");
    // Get the player id from iMask
        new iPlayer = GetPlayerIDFromMaskID(iMask);
    if(iPlayer== -1 || !IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
    if(iAmount < 1 || iAmount > HandMoney(playerid)) return SendClientError(playerid, "Invalid amount specified!");
    if(PlayerInfo[playerid][pMaskID]) return SendClientError(playerid, "Invalid stranger mask");
        // if(iPlayer == playerid)  return SendClientError(playerid, "You cannot pay yourself!");
    if(iAmount > 5000000) return SendClientError(playerid, "You can pay maximum $5,000,000 at a time!");
 if(PlayerInfo[playerid][totalpayt] < 3 && iAmount > 10000 && (GetPVarInt(playerid, "PayTimer") == 0)) return SendClientError(playerid, "New players can pay $10,000 per minute!");
    if(GetDistanceBetweenPlayers(playerid, iPlayer) > 6) return SendClientError(playerid, "He is too far away!");
    if(GetTickCount() - PlayerTemp[playerid][cmdtick] < 3000) return SendClientWarning(playerid, "You may use this command only once in 3 seconds.");
    new ip1[ 24 ], ip2[ 24 ];
    GetPlayerIp(playerid, ip1, sizeof(ip1));GetPlayerIp(iPlayer, ip2, sizeof(ip2));
    SetPVarInt(playerid, "PayTimer", 0);
    SetTimerEx("PTime", 60000, false, "i", playerid);
     if(PlayerTemp[playerid][totallogin] == 1 && iAmount > 100000) return SendClientWarning(playerid, "You may not transfer this amount of money as a new player.");
    if(!strcmp(ip1,ip2,true))
    {
        format(iStr, sizeof(iStr), "** /pay warning: %s and %s same IP (%s) - Amount: $%d", PlayerName(playerid), PlayerName(iPlayer), ip1, iAmount);
        SendClientMessageToAdmins(iStr,COLOR_HELPEROOC);
    }
    GivePlayerMoneyEx(playerid,-iAmount);GivePlayerMoneyEx(iPlayer, iAmount);
    format(iStr, sizeof(iStr), "takes out some money and hands it to %s.", MaskedName(iPlayer));
    Action(playerid, iStr);
    format(iStr, sizeof(iStr),  "[CASH]: You have given %s $%s.", MaskedName(iPlayer),AddCommasToInt(iAmount));
    SendClientMessage(playerid, COLOR_YELLOW, iStr);
    format(iStr, sizeof(iStr), "[CASH]: You have recieved $%s from %s", AddCommasToInt(iAmount),MaskedName(playerid));
    SendClientMessage(iPlayer, COLOR_YELLOW, iStr);
    format(iStr,sizeof(iStr),"14[MONEY] %s has paid $%s to %s.", PlayerName(playerid), AddCommasToInt(iAmount), PlayerName(iPlayer));
    iEcho(iStr); AppendTo(moneylog,iStr);
    }
Reply
#7

Thanks for your time and helping me with this Repped +
ill test later
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)