SA-MP Forums Archive
SSCANF - 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: SSCANF (/showthread.php?tid=302570)



SSCANF - Azzeto - 09.12.2011

Alright, so I decided to create a Cops And Robbers server and now i'm going to use SSCANF2 instead of the old sscanf, So I created my first command to help me with my scripting

PHP код:
CMD:vspawn(playerid,params[])
{
    new
        
Float:x,Float:y,Float:z,Float:a,
        
vehid;
    if(
sscanf(params,"i",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
    else if(
vehid 400 || vehid 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");
    else
    {
        
GetPlayerFacingAngle(playerid,a);
        
GetPlayerPos(playerid,x,y,z);
        
vehid CreateVehicle(vehid,x,y,z,a,-1,-1,5000);
        
PutPlayerInVehicle(playerid,vehid,0);
    }
    return 
1;

But it gives me errors on the sscanf line and to check if the vehid is in range of the working ids, saying

Код:
C:\Documents and Settings\Customer\Desktop\Cops And Robbers\gamemodes\cnr.pwn(315) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Customer\Desktop\Cops And Robbers\gamemodes\cnr.pwn(316) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
How come?


Re: SSCANF - T0pAz - 09.12.2011

Try this

pawn Код:
CMD:vspawn(playerid,params[])
{
    new
        Float:PosX,Float:PosY,Float:PosZ,Float:PosA,
        vehid,
        vehiclez
    ;
    if(sscanf(params,"i",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
    else if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");
    else
    {
        GetPlayerFacingAngle(playerid,PosA);
        GetPlayerPos(playerid,PosX,PosY,PosZ);
        vehiclez = CreateVehicle(vehid,x,y,z,a,-1,-1,5000);
        PutPlayerInVehicle(playerid,vehiclez,0);
    }
    return 1;
}



Re: SSCANF - Azzeto - 09.12.2011

Thanks for the help, but that didn't help.


Re: SSCANF - T0pAz - 09.12.2011

show us the error line


Re: SSCANF - Azzeto - 09.12.2011

Код:
	if(sscanf(params,"i",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
	else if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");



Re: SSCANF - Jakku - 09.12.2011

pawn Код:
CMD:vspawn(playerid,params[])
{
    new
        Float:x,Float:y,Float:z,Float:a,vehid,vehicle;

    if(sscanf(params,"d",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
    if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");

        GetPlayerFacingAngle(playerid,a);
        GetPlayerPos(playerid,x,y,z);
 
        vehicle = CreateVehicle(vehid,x,y,z,a,-1,-1,5000);
        PutPlayerInVehicle(playerid,vehicle,0);

    return 1;
}



Re: SSCANF - Azzeto - 09.12.2011

I don't see what you changed besides the param, i and d are the same thing..


Re: SSCANF - Jakku - 09.12.2011

That was not the problem actually.
Also, you can't use "vehid" when you put the player to the vehicle, that's the MODEL id, not the vehicle id. Try it


Re: SSCANF - Azzeto - 09.12.2011

I can use vehid because it's just a variable, I'v used it on my other gamemode(freeRoam) with sscanf 1 and it worked fine.

and what do you mean "That was not the problem actoully"


Re: SSCANF - Jakku - 09.12.2011

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
I can use vehid because it's just a variable, I'v used it on my other gamemode(freeRoam) with sscanf 1 and it worked fine.
Oh yeah, of course you can. My bad.

And I just decided to change it, the problem in your code was this:

pawn Код:
if(sscanf(params,"i",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
else if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");
Should be:

pawn Код:
if(sscanf(params,"i",vehid)) return SendClientMessage(playerid,COLOR_WHITE,"** Format ** /vspawn [vehid]");
if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,COLOR_WHITE,"Vehicle ID's range from 400-611.");