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



Halp! - iBeast - 13.10.2013

pawn Код:
CMD:vl(playerid, params[])
{
    if(PlayerInfo[playerid][Level] >=5 || IsPlayerAdmin(playerid))
    {
        if(PlayerInfo[playerid][OnDuty] == 0) return SCM(playerid, C_RED, "You're not on duty");
        if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, C_RED, "You need to be in a vehicle");
        new Float:VLX, Float:VLZ, Float:VLY;
        new tmp1[256], tmp2[256], tmp3[256];
        new string[128], Index; tmp1 = strtok(params, Index); tmp2 = strtok(params, Index); tmp3 = strtok(params, Index);
        if(isnull(tmp1) || isnull(tmp2) || isnull(tmp3)) return SCM(playerid, C_RED, "Usage: /vl [X], [Y], [Z]");
        VLX = strval(tmp1);        VLY = strval(tmp2);          VLZ = strval(tmp3);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), VLX, + VLY, + VLZ); //Line 10364 o.o
    }
    else return SendClientMessage(playerid,red, "[ERROR]: You are not a high enough level to use this command");
    return 1;
}
errors given by it:

Код:
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : error 029: invalid expression, assumed zero
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : warning 215: expression has no effect
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : error 029: invalid expression, assumed zero
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : warning 215: expression has no effect
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : error 001: expected token: ";", but found ")"
D:\San Andreas\A Script Folder\gamemodes\asdfaa.pwn(10364) : fatal error 107: too many error messages on one line
I tried thousand times but didnt get this code right if anyone could help?


Re: Halp! - ]Rafaellos[ - 13.10.2013

You have "+ VLY" and "+ VLZ" but you don't give it anything to plus with.


Re: Halp! - iBeast - 13.10.2013

you mean another float?


Re: Halp! - Konstantinos - 13.10.2013

What are you trying to do with '+' symbol?

pawn Код:
SetVehicleVelocity(GetPlayerVehicleID(playerid), VLX, VLY, VLZ);



Re: Halp! - iBeast - 13.10.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
What are you trying to do with '+' symbol?

pawn Код:
SetVehicleVelocity(GetPlayerVehicleID(playerid), VLX, VLY, VLZ);
Actually I was thinking of something else but that fixed it so i'll stick to it.


Re: Halp! - Konstantinos - 13.10.2013

Can I also suggest you something? It's better to use sscanf for splitting the string (for the parameters) because strtok is really bad. Also take a look here:
pawn Код:
new tmp1[256], tmp2[256], tmp3[256];
new string[128]
Do you really need all these? Except the string that is not used, the rest with even size of 16 are fine. Floats cannot be more than lenght 12.


Re: Halp! - iBeast - 13.10.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Can I also suggest you something? It's better to use sscanf for splitting the string (for the parameters) because strtok is really bad. Also take a look here:
pawn Код:
new tmp1[256], tmp2[256], tmp3[256];
new string[128]
Do you really need all these? Except the string that is not used, the rest with even size of 16 are fine. Floats cannot be more than lenght 12.
You got a point actually, and So I fixed it.
Thanks for the help Konstantinos.