Trunk code - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Trunk code (
/showthread.php?tid=170527)
Trunk code -
vection - 23.08.2010
Part of the command problem:
pawn Код:
if(strcmp(cmd, "/trunk2", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new x_job[256];
x_job = strtok(cmdtext, idx);
if(!strlen(x_job)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /trunk [ID] [Ammo]");
return 1;
}
new level;
level = strval(tmp);
new Weap, Ammo;
new car = GetClosestVehicle(playerid);
if(VehicleInfo[car][vT] == 1 || vehiclelocked[car] == 0)
{
if(strcmp(x_job,"24",true) == 0)
{
...............
the problem is.. new level; should to be [Ammo] but is doesnt work well.
everytime when i write the command the ammo set to 0 so i think the problem in new level; level = straval(tmp);
please how to fix it well..
Re: Trunk code -
Finn - 23.08.2010
Maybe start using
sscanf (+ zcmd)?
Makes things easier for you.
Re: Trunk code -
vection - 23.08.2010
never mind i found the problem.
Re: Trunk code -
Kyosaur - 23.08.2010
Quote:
Originally Posted by Finn
Maybe start using sscanf (+ zcmd)?
Makes things easier for you.
|
I agree with Mr.Finn. Sscanf is not only easier, but it offers more features, and beats it in speed.
as for your problem with "level", its because of this:
Код:
new level;
level = strval(tmp);
You are pulling tmp out of no where? Add another strtok statment but this time with tmp=strtok(cmdtext,idx); THEN use strval and store the integer inside of "level".