SA-MP Forums Archive
Problem with /v buy - 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: Problem with /v buy (/showthread.php?tid=282333)



Problem with /v buy - [IL]HeHu - 10.09.2011

Here is the command:
PHP Code:
                CMD:vehicle(playeridparams[])
{
    new
        
para1[20]
    ;
    if(
sscanf(params,"s[20]",para1))
    {
        
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/vehicle [action]");
        
SendClientMessage(playerid,C_NICE,"[Actions] {FFFFFF}buy, sell, park, lock, get, paint, register, unregister");
        
SendClientMessage(playerid,C_NICE,"[Actions] {FFFFFF}buyinsurance, buylock, buyalarm, buygps, garage, find");
        
SendClientMessage(playerid,C_NICE,"[Actions] {FFFFFF}list, info, tow, faction, destroy");
    }
    
printf("%s",para1);
    if(
equal(para1,"buy",true))
    {
        if(!
IsPlayerInRangeOfPoint(playerid,5.0,545.1452,-1288.2523,17.2422))
            return 
SendClientMessage(playerid,C_RED,"You have to be next to a dealership");
        new
            
vid,
            
c[2]
        ;
        if(
sscanf(params,"s[20]iii",para1,vid,c[0],c[1]) || vid 400 || vid 603 || c[0] < || c[0] > 255 || c[1] < || c[1] > 255)
        {
            
SendClientMessage(playerid,C_YELLOW,"[Landstalker, 400, $72,000] [Buffalo, 402, $182,000] [Sentinel, 405, $64,999] [Trashmaster, 408, $31,200] [Stretch, 409, $320,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Manana, 410, $18,500] [Voodoo, 412, $53,000] [Cheetah, 415, $750,000] [Taxi, 420, $36,500] [Washington, 421, $62,500] [Bobcat, 422, $13000]");
             
SendClientMessage(playerid,C_YELLOW,"[Premier, 426, $65,000] [Hotknife, 434, $190,000] [Coach, 437, $112,000] [Cabbie, 438, $32,000] [Admiral, 445, $39,000] [Oceanic, 467, $38,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Hermes, 474, $35,000] [Sabre, 475, $45,000] [ZR-350, 477, $500,000] [Regina, 479, $23,500] [Comet, 480, $130,000] [Burrito, 482, $34,000]");
              
SendClientMessage(playerid,C_YELLOW,"[Rancher, 489, $130,000] [Virgo, 491, $30,000] [Greenwood, 492, $32,000] [Balista Compact, 496, $45,000] [Mesa, 500, $34,000] [Super GT, 506, $420,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Elegant, 507, $50,000] [Journey, 508, $80,000] [Nebula, 516, $28,000] [Majestic, 517, $40,000] [Buccaneer, 518, $40,000] [Towtruck, 525, $20,000]");
             
SendClientMessage(playerid,C_YELLOW,"[Fortune, 526, $38,000] [Willard, 529, $42,000] [Feltzer, 533, $39,000] [Remington, 534, $39,000] [Slamvan, 535, $26,500] [Blade, 536, $30,000]");
              
SendClientMessage(playerid,C_YELLOW,"[Vincent, 540, $50,000] [Bullet, 541, $1,000,000] [Clover, 542, $40,000] [Huslter, 545, $60,000] [Intruder, 546, $27,000] [Primo, 547, $21,500]");
              
SendClientMessage(playerid,C_YELLOW,"[Tampa, 549, $30,000] [Sunrise, 550, $45,000] [Merit, 551, $32,000] [Yosemite, 544, $32,000] [Windsor, 555, $70,000] [Uranus, 558, $62,000]");
               
SendClientMessage(playerid,C_YELLOW,"[Jester, 559, $80,000] [Sultan, 560, $280,000] [Startum, 561, $50,000] [Elegy, 562, $80,000] [Tahoma, 566, $33,000] [Savanna, 567, $33,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Broadway, 575, $50,000] [Huntley, 579, $120,000] [Stafford, 580, $45,000] [Wayfarer, 586, $20,000] [Euros, 587, $65,000] [Hotdog, 588, $28,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Club, 589, $62,000] [Alpha, 602, $62,000] [Phoenix, 603, $400,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Pizza boy, 448, $5,000] [PCJ 600, 461, $200,000] [Faggio, 462, $5,000] [Freeway, 463, $82,000] [Sanchez, 468, $82,000] [FCR-900, 521, $200,000]");
            
SendClientMessage(playerid,C_YELLOW,"[Squallo, 446, $420,000] [Speeder, 452, $225,000] [Tropic, 545, $500,000] [Dinghy, 473, $15,000] [Maverick, 487, $2,200,000]");
            
SendClientMessage(playerid,C_GREEN,"_______________Format: [Vehicle Name, Vehicle ID, Vehicle Price]_______________");
            
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/(v)ehicle buy [id] [color 1] [color 2]");
            
printf("%s | %i | %i | %i",para1,vid,c[0],c[1]);
            return 
1;
        } 
I already know what the problem is, it counts the variable 'para1' as the whole text I write
For example:
IG I do /v buy 560 0 0
and it's supposed to be:
buy - para1
560 - vid
0 - c[0]
0 - c[1]
But for some reason it puts everything into the variable para1.
Can anyone see a problem with my code, and if so, can you tell me how to fix it?