SA-MP Forums Archive
Adding more crimes with 1 command - 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)
+--- Thread: Adding more crimes with 1 command (/showthread.php?tid=582256)



Adding more crimes with 1 command - Lajko1 - 19.07.2015

How can I make the code so it will write another crime not rewrite the current one ?
Current cmd is rewriting only 1 crime but I want this command to actually add another crime every time it's used on someone.

pawn Код:
CMD:makewanted(playerid,params[])
{
    new id, reason[80], string[50];
    if(sscanf(params, "us[80]",id ,reason)) return SendClientMessage(playerid,-1,"USAGE: /makewanted [PlayerID/Part of Name] [Reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player Not connected");
    format(PlayerInfo[id][pCrimes], 80, reason);
    new INI:File = INI_Open(UserPath(id));
    INI_WriteString(File,"Crimes",PlayerInfo[id][pCrimes]);
    INI_Close(File);

    format(string, sizeof(string), "Crime %s saved", reason);
    SendClientMessage(playerid, -1, string);
    return 1;
}



Re: Adding more crimes with 1 command - Lajko1 - 20.07.2015

Bump


Re: Adding more crimes with 1 command - Evocator - 20.07.2015

Код:
CMD:makewanted(playerid,params[])
{
	new 
		id, 
		reason[80], 
		string[50]
	;

    if(sscanf(params, "us[80]", id ,reason)) 
    	return SendClientMessage(playerid,-1,"USAGE: /makewanted [PlayerID/Part of Name] [Reason]");

   	if(!IsPlayerConnected(id)) 
   		return SendClientMessage(playerid, -1, "Player Not connected");

   	format(PlayerInfo[id][pCrimes], 80, "%s,%s", PlayerInfo[id][pCrimes], reason);

    new INI:File = INI_Open(UserPath(id));
    INI_WriteString(File,"Crimes",PlayerInfo[id][pCrimes]);
    INI_Close(File);

    format(string, sizeof(string), "Crime %s saved", reason);
    SendClientMessage(playerid, -1, string);

	return 1;
}
So it will be saved as: OldCrime,NewCrime.
Another added crime will be as: OldestCrime,OldCrime,NewCrime. And so on..


Re: Adding more crimes with 1 command - Lajko1 - 20.07.2015

Damn thank you a lot was seeking for this part of code for 1 week, + rep for you!


Re: Adding more crimes with 1 command - Lajko1 - 21.07.2015

Umm 1 more thing, how can I display this in rows? so it will display like:
-crime 1
-crime 2
-crime 3

not

crime 1, crime 2, crime 3?