Need help with params -
Zigonja - 29.06.2013
Okay, Im not sure if these are params witch will I ask you to help me with but if you get the idea I'd like you to help me
Here is the code (it works)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/loadlogs", cmdtext, true, 10) == 0)
{
new cID = GetPlayerVehicleID(playerid);
if(CarInfo[cID][logloaded] == 0)
{
if(IsATruck(cID))
{
if(GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), -1419.1344,-297.8153,13.6995) <= 10 )
{
CarInfo[cID][logloaded] = 1;
GivePlayerMoney(playerid, -3000);
SendClientMessage(playerid, COLOR_GREEN, "You've loaded your truck with logs, and paid 3000$ for it");
}
else return SendClientMessage(playerid, COLOR_RED, "You're not in range of loading point.");
}
else return SendClientMessage(playerid, COLOR_RED, "You're not in truck.");
}
else return SendClientMessage(playerid, COLOR_RED, "Your truck is loaded already, go and unload.");
return 1;
}
if (strcmp("/unloadlogs", cmdtext, true, 10) == 0)
{
new cID = GetPlayerVehicleID(playerid);
if(CarInfo[cID][logloaded] == 1)
{
if(GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), 1529.6150,-1691.1863,13.0234) <= 10 )
{
new cash = random(15000-3000)+3000;
new string[128];
GivePlayerMoney(playerid, cash);
format(string,sizeof(string), "You've earned %i$ from the delivery.",cash);
CarInfo[cID][logloaded] = 0;
SendClientMessage(playerid, COLOR_GREEN, "You've unloaded your logs.");
SendClientMessage(playerid, COLOR_GREEN, string);
}
else return SendClientMessage(playerid, COLOR_RED, "You're not in range of unloading point.");
}
else return SendClientMessage(playerid, COLOR_RED, "Your truck is empety, go and load it first.");
return 1;
}
return 0;
}
Now, what I want is that, I could use /loadlogs "1" or "2" or "3" up to 100. And if I typed "1" it would cost 300$ and I would get 850$ for it. I have no idea how to make this, so if you showed me how to make like one, or two I'll then make others myself, thanks in advance!
Re: Need help with params -
Zigonja - 29.06.2013
I got lost when there was
pawn Код:
else if ...
else ...
else ...
but there was no command to continiue
Re: Need help with params -
Zigonja - 29.06.2013
But, why would I use sscanf if I can barely understand strcmp?
Anyway I want to do something like this :
pawn Код:
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0) // By LordMan
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You need to login first ! ");
return 1;
}
new x_nr[64];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: /test [1]");
return 1;
}
if(strcmp(x_nr,"1",true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: /test [1]");
}
Re: Need help with params -
Zigonja - 29.06.2013
Okay I get it, it's easyer, but that still doesn't answer mine question
Re: Need help with params -
Zigonja - 29.06.2013
May you show me an example please?