SSCANF
#1

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

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;
}
Reply
#3

Thanks for the help, but that didn't help.
Reply
#4

show us the error line
Reply
#5

Код:
	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.");
Reply
#6

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;
}
Reply
#7

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

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
Reply
#9

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"
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)