SA-MP Forums Archive
Scripting help, please HELP! - 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: Scripting help, please HELP! (/showthread.php?tid=396654)



Scripting help, please HELP! - GLE - 01.12.2012

I use zcmd gamemode and i buy for 24/7 flowers.
How to create command zcmd /give flover to player?
Please help me!


Re : Scripting help, please HELP! - [HRD]Mar1 - 01.12.2012

Hi!

Could you more explain ?


Re: Scripting help, please HELP! - GLE - 01.12.2012

If i bought flowers with shop, i can share flowers with other player..


example: /giveflowers [PlayerID]
Player gets flower and i lose flower.
I need this script.

(( Sorry i I do not speak much English. ))


Re : Scripting help, please HELP! - [HRD]Mar1 - 01.12.2012

Код HTML:
	new
		index,
		cmd[20];
	cmd = strtok(cmdtext, index);
	if (strcmp(cmd, "/giveflower", true) == 0)
	{
		new
			tmp[20],
			id;
		tmp = strtok(cmdtext, index);
		if (strlen(tmp))
		{
			id = strval(tmp);
			if (IsPlayerConnected(id))
			{
				GivePlayerWeapon(id,14,1);
                                GivePlayerWeapon(playerid,14,0);
				SendClientMessage(id, 0x00FF00AA, "You have recived a flower!");
				SendClientMessage(playerid, 0x00FF00AA, "You have send a flower");
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "Player not found");
			}
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/giveflower <playerid>\"");
		}
		return 1;
	}



Re: Scripting help, please HELP! - GLE - 01.12.2012

I use zcmd gamemode, please create this command in zcmd please.


Re : Scripting help, please HELP! - [HRD]Mar1 - 01.12.2012

Код HTML:
CMD:flowers(playerid, params[]) {
    new id, message[1024],szString[1024];
    if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveflowers <playerid>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
    if(playerid != id) {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        new ReturnName[MAX_PLAYER_NAME];
        GetPlayerName(id, ReturnName, sizeof(ReturnName));
        format(szString,sizeof(szString), "You have send flowers to %s", ReturnName);
        SendClientMessage(playerid, 0xFFCC2299, szString);
        format(szString,sizeof(szString),"You have recived flowers from %s!",PlayerName);
        SendClientMessage(id, 0xFFFF22AA, szString);
        GivePlayerWeapon(id,14,1);
        GivePlayerWeapon(playerid,14,0);
    }
    else {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot give the flowers for yourself! :O");
    }
    return 1;
}



Re: Re : Scripting help, please HELP! - Konstantinos - 01.12.2012

Quote:
Originally Posted by [HRD]Mar1
Посмотреть сообщение
Код HTML:
CMD:flowers(playerid, params[]) {
    new id, message[1024],szString[1024];
    if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveflowers <playerid>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
    if(playerid != id) {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        new ReturnName[MAX_PLAYER_NAME];
        GetPlayerName(id, ReturnName, sizeof(ReturnName));
        format(szString,sizeof(szString), "You have send flowers to %s", ReturnName);
        SendClientMessage(playerid, 0xFFCC2299, szString);
        format(szString,sizeof(szString),"You have recived flowers from %s!",PlayerName);
        SendClientMessage(id, 0xFFFF22AA, szString);
        GivePlayerWeapon(id,14,1);
        GivePlayerWeapon(playerid,14,0);
    }
    else {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot give the flowers for yourself! :O");
    }
    return 1;
}
Jesus! You need to learn how to use sscanf first before you post code that it will give him errors/warning.
pawn Код:
new id, message[1024],szString[1024];
if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveflowers <playerid>");
Your usage is "/giveflowers <integer> <string of 1024>.
when it needs to be
pawn Код:
new id;
if(sscanf(params,"r",id))return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveflowers <playerid>");