07.05.2011, 21:19
Hello. I am currently scripting a /give command. And i dont know how to do it in ZCMD + SSCANF.
This is what i got so far:
And i get all this errors:
Line 2665:
Line 2668:
How do i solve this?
This is what i got so far:
pawn Код:
CMD:give(playerid,params[])
{
new giveplayerid;
new giveplayer[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new option[256];
if(sscanf(params, "u", giveplayer))
return SendClientMessage(playerid, RED, "[LOST:RP] /give [ID] [OPTION");
return SendClientMessage(playerid, RED, "[LOST:RP] Options: Matches,Firewood,WaterBottle,FishingRod,FishingNet,Heroin");
if(giveplayerid == playerid)
return SendClientMessage(playerid, RED, "[LOST:RP] You cant give yourself stuff");
{
if(params(option,"Matches",true) == 0)
{
if(PlayerInfo[playerid][pMatches] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pMatches] -= 1;
PlayerInfo[giveplayer][pMatches] += 1;
format(string, sizeof(string), "%s hands some matches to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have any matches to give");
}
}
if(params(option,"Firewood",true) == 0)
{
if(PlayerInfo[playerid][pWood] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pWood] -= 1;
PlayerInfo[giveplayer][pWood] += 1;
format(string, sizeof(string), "%s hands fire wood to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have any firewoods to give");
}
}
if(params(option,"WaterBottle",true) == 0)
{
if(PlayerInfo[playerid][pWaterBottle] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pWaterBottle] -= 1;
PlayerInfo[giveplayer][pWaterBottle] += 1;
format(string, sizeof(string), "%s hands a WaterBottle to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have any WaterBottles");
}
}
if(params(option,"FishingRod",true) == 0)
{
if(PlayerInfo[playerid][pFishingRod] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pFishingRod] -= 1;
PlayerInfo[giveplayer][FishingRod] += 1;
format(string, sizeof(string), "%s hands a Fishing Rod to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have a Fishing Rod");
}
}
if(params(option,"FishingNet",true) == 0)
{
if(PlayerInfo[playerid][pFishingNet] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pFishingNet] -= 1;
PlayerInfo[giveplayer][pFishingNet] += 1;
format(string, sizeof(string), "%s hands a Fishing Net to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have a Fishing Net");
}
}
if(params(option,"Heroin",true) == 0)
{
if(PlayerInfo[playerid][pHeroin] > 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[playerid][pHeroin] -= 1;
PlayerInfo[giveplayer][pHeroin] += 1;
format(string, sizeof(string), "%s hands a bag of heroin to %s", sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You dont have any heroin");
}
}
return 1;
}
}
Код:
(2665) : warning 225: unreachable code (2668) : error 012: invalid function call, not a valid address (2668) : warning 215: expression has no effect (2668) : warning 215: expression has no effect (2668) : warning 215: expression has no effect (2668) : error 001: expected token: ";", but found ")" (2668) : error 029: invalid expression, assumed zero (2668) : fatal error 107: too many error messages on one line
Код:
CMD:give(playerid,params[])
Код:
if(params(option,"Matches",true) == 0)