How to make a variable save on filterscript reload?
#1

My code:

Код:
COMMAND:sshelp(playerid, params[])
{
    if(pInfo[playerid][pSS] == 1)
    {
    	SendClientMessage(playerid, COLOR_GREEN, "/ssduty /ssuninvite /showssbadge /quitss (quit SS) /ssr (radio)");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not in SS.");
   	}
	return 1;
}
COMMAND:ssuninvite(playerid, params[])
{
	new targetid3;
    if(sscanf(params, "u", targetid3)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /ssuninvite [PlayerID]");
    if(pInfo[targetid3][pSS] >= 1)
    {
    pInfo[targetid3][pSS] = 0;
   	SendClientMessage(targetid3, COLOR_YELLOW, "You have been uninvited from SS.");
	}
	return 1;
}
COMMAND:makessleader(playerid, params[])
{
	new targetid1;
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not an admin");
    if(sscanf(params, "u", targetid1)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /makessleader [PlayerID]");
    if(pInfo[targetid1][pSS] == 1) return SendClientMessage(playerid, COLOR_RED, "That player is already in SS.");
   	SetPlayerSkin(targetid1, 294);
	pInfo[targetid1][pSS] = 1;
 	OnPlayerSave(targetid1);
	SendClientMessage(targetid1, COLOR_YELLOW, "You have been made the leader of Secret Society.");
    return 1;
}

COMMAND:showssbadge(playerid, params[])
{
    new targetid1;
    if(sscanf(params, "u", targetid1)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /showssbadge [PlayerID]");
    if(pInfo[playerid][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not in SS.");
    if(pInfo[playerid][pSS] == 1)
    {
    SendClientMessage(targetid1, COLOR_WHITE, "************************");
    SendClientMessage(targetid1, COLOR_BLUE, "Secret Society");
    SendClientMessage(targetid1, COLOR_BLUE, "Government Agent");
    SendClientMessage(targetid1, COLOR_BLUE, "Los Santos");
    SendClientMessage(targetid1, COLOR_WHITE, "************************");
	}
    return 1;
}
COMMAND:quitss(playerid, params[])
{
    if(pInfo[playerid][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not in SS.");
    if(pInfo[playerid][pSS] == 1)
	pInfo[playerid][pSS] = 0;
	SendClientMessage(playerid, COLOR_YELLOW, "You have quitted Secret Society.");
	return 1;
}
COMMAND:removefromss(playerid, params[])
{
	new targetid2;
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not an admin");
    if(sscanf(params, "u", targetid2)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /removefromss [PlayerID]");
    if(pInfo[targetid2][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "That player is not in SS.");
    else
    {
   		pInfo[targetid2][pSS] = 0;
     	SendClientMessage(targetid2, COLOR_YELLOW, "You are no longer in Secret Society.");
	   }
    return 1;
}
COMMAND:ssduty(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,326.8698,307.2567,999.1484,2)) return SendClientMessage(playerid, COLOR_YELLOW, "You are too far away from the Locker.");
    if(pInfo[playerid][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not in SS!");
    if(pInfo[playerid][pSS] == 1)
    ShowPlayerDialog(playerid, 8000, DIALOG_STYLE_LIST, "Choose your equipment", "Night Stick\nGrenade\nTear Gas\nSilenced 9mm\nShotgun\nMP5\nM4\nSniper Rifle\nSpray Can\nCamera\nNight Vision Goggles\nThermal Goggles", "Take", "Cancel");
    return 1;
}
CMD:sscuff(playerid,params[])
{
    if(pInfo[playerid][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not in SS!");
    if(pInfo[playerid][pSS] == 1)
    if(!sscanf(params, "u", targetid4))
    {
        SendClientMessage(targetid4, 0xFF0000AA, "* You are now cuffed.");
        SetPlayerSpecialAction(targetid4, SPECIAL_ACTION_CUFFED);
        SetPlayerAttachedObject(targetid4, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
    }
    else return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]Usage: /cuff [ID]");
    return 1;
}

CMD:ssuncuff(playerid,params[])
{
    if(pInfo[playerid][pSS] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not in SS!");
    if(pInfo[playerid][pSS] == 1)
    if(sscanf(params, "u", cufftarget)) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] /uncuff [ID] ");
    for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
    {
        if(IsPlayerAttachedObjectSlotUsed(cufftarget, i))
        {
            SetPlayerSpecialAction(cufftarget, SPECIAL_ACTION_NONE);
            RemovePlayerAttachedObject(cufftarget, i);
        }
        else return 0;
    }
    return 1;
}
My question is how to make this save when a player logs in and out, and the filterscript is reloaded. The variable is:

if(pInfo[playerid][pSS] == 1) or pInfo[playerid][pSS] = 0;

Please help me!
Reply
#2

-removed-

but if you want the variable still active when the filterscript is reloaded, use SetPVarInt and GetPVarInt
Reply
#3

can you please make an example here? of what i have written here?
Reply


Forum Jump:


Users browsing this thread: