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



Variable help. - Snipa - 08.02.2011

I have an "admin car" test script thingie.

Код:
new Admincar;
Код:
public OnGameModeInit()
{
	Admincar == AddStaticVehicle(411,-1372.1838,-242.7996,13.7163,314.2817,118,20);
	return 1;
}
Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
	if(GetVehicleModel(vehicleid) == Admincar
	{
		SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
	}
	return 1;
}
Код:
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1624) : warning 215: expression has no effect
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1865) : error 028: invalid subscript (not an array or too many subscripts): "Admincar"
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1866) : error 017: undefined symbol "playerid"
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1868) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Line 1624:
Код:
Admincar == AddStaticVehicle(411,-1372.1838,-242.7996,13.7163,314.2817,118,20);
The three others are from OnVehicleStreamIn.

I'm kinda new on variables+some other stuff. If anyone can be my tutor, pm me, of course if you want to.


Re: Variable help. - Antonio [G-RP] - 08.02.2011

It's FORPLAYERID, not PLAYERID. Also, you didn't close the bracket on the if(GetVehModel...
Also (again), you can't do GetVehicleModel(vehicleid) == Admincar, try this...

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if(vehicleid == Admincar)
    {
        SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
    }
    return 1;
}



Re: Variable help. - Snipa - 08.02.2011

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
It's FORPLAYERID, not PLAYERID. Also, you didn't close the bracket on the if(GetVehModel...

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if(GetVehicleModel(vehicleid) == Admincar)
    {
        SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
    }
    return 1;
}
My mistake! But its says "Expression has no effect" for my variable on OnGameModeInit


Re: Variable help. - Antonio [G-RP] - 08.02.2011

You must change

Код:
new Admincar;
to

pawn Код:
new Admincar[MAX_VEHICLES];
Check my edited reply.


Re: Variable help. - Snipa - 08.02.2011

Код:
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1624) : error 033: array must be indexed (variable "Admincar")
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1864) : error 033: array must be indexed (variable "Admincar")



Re: Variable help. - Antonio [G-RP] - 08.02.2011

under OnGameModeInit()

pawn Код:
Admincar = AddStaticVehicle(411,-1372.1838,-242.7996,13.7163,314.2817,118,20);



Re: Variable help. - Snipa - 08.02.2011

Still says it needs to be indexed.


Re: Variable help. - iFriSki - 08.02.2011

Quote:
Originally Posted by Snipa
Посмотреть сообщение
Still says it needs to be indexed.
You're not working with an array. Why would you for this?


Re: Variable help. - Snipa - 08.02.2011

Quote:
Originally Posted by iFriSki
Посмотреть сообщение
You're not working with an array. Why would you for this?
Sorry, you posted before I did + I didn't see it. Anyways thanks.


Re: Variable help. - Snipa - 08.02.2011

Been some time since I scripted, when I make the command:



Код:
command(v,playerid,params[])
{
	new tmp[256];
	tmp = strtok(cmdtext,idx);
	
	new model = strval(tmp);
	if(!strlen(tmp)){
        SendClientMessage(playerid, COLOR_RED, "Usage: /v [vehicleid]");
        return 1;
	}
	
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid,x,y,z);
	new Float:a;
	GetPlayerFacingAngle(playerid,a);
	CreateVehicle(model,x,y+2,z+1,a,0,0,0);
	
	new string[128]
	format(string,sizeof(string),"You have created vehicle: %d",model);
	SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
	return 1;
}
Errors:

Код:
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1769) : error 017: undefined symbol "cmdtext"
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(1784) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.