SA-MP Forums Archive
Foreach & GetPlayerVehicleID - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Foreach & GetPlayerVehicleID (/showthread.php?tid=232277)



Foreach & GetPlayerVehicleID - Mike Garber - 27.02.2011

Well because a timer didn't seem to work I made debug messages, and It seems like
it doesn't work to GetPlayerVehicleID inside a Foreach loop?

I get this error when I compile;
error 035: argument type mismatch (argument 1)
pawn Код:
foreach(Player,i)
    {
        print("Foreach");
        if(GetPlayerState(i)==PLAYER_STATE_DRIVER)
        {
            print("IfStateDriver");
            vehicleid = GetPlayerVehicleID(i);
            print(vehicleid); // here



Re: Foreach & GetPlayerVehicleID - Gh0sT_ - 27.02.2011

new vehicleid = GetPlayerVehicleID( i );


Re: Foreach & GetPlayerVehicleID - Mike Garber - 27.02.2011

That is the same code as I've written, only that i've made the variable above so i wouldn't create new variables everytime it loops.


Re: Foreach & GetPlayerVehicleID - dice7 - 27.02.2011

the function "print" has a string argument, not integer


Re: Foreach & GetPlayerVehicleID - Calgon - 27.02.2011

You're trying to simply print an integer, print() expects strings.

Use printf and format the printing:

pawn Код:
printf("vehicleid: %d", vehicleid);



Re: Foreach & GetPlayerVehicleID - Mike Garber - 27.02.2011

Quote:
Originally Posted by dice7
Посмотреть сообщение
the function "print" has a string argument, not integer
OK, but the thing is I have an If statement using this integer (vehicleid) and It isn't executed,
it bypasses that if statement. So I think it has to do with this.


Re: Foreach & GetPlayerVehicleID - Calgon - 27.02.2011

So change your code with the printf example I gave you and try debug again.