Trunk code
#1

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..
Reply
#2

Maybe start using sscanf (+ zcmd)?

Makes things easier for you.
Reply
#3

never mind i found the problem.
Reply
#4

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".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)