problem with stock function - 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: problem with stock function (
/showthread.php?tid=347528)
problem with stock function -
niels44 - 02.06.2012
hey guys,
im trying to make this kinda stock with " and " but it doesnt works quite good...
can someone tell me whats wrong with this?
pawn Код:
stock RespawnAtRace(vehicleid, race[])
{
if(race == "MDrag")
{
new Random = random(sizeof(RandomSpawnsMDrag));
SetVehiclePos(vehicleid, RandomSpawnsMDrag[Random][0], RandomSpawnsMDrag[Random][1], RandomSpawnsMDrag[Random][2]);
SetVehicleZAngle(vehicleid, RandomSpawnsMDrag[Random][3]);
}
else if(race == "MDrift")
{
new Random = random(sizeof(RandomSpawnsMDrift));
SetVehiclePos(vehicleid, RandomSpawnsMDrift[Random][0], RandomSpawnsMDrift[Random][1], RandomSpawnsMDrift[Random][2]);
SetVehicleZAngle(vehicleid, RandomSpawnsMDrift[Random][3]);
}
}
and this i use in another callback:
pawn Код:
RespawnAtRace(vehicleid, "MDrift");
// and another callback
RespawnAtRace(vehicleid, "MDrag");
the problem is that i want it that i can use " and " for the MDrag things, but i dont know whats the problem here...
anyone sees the problem?

greets niels
Re: problem with stock function -
MadeMan - 02.06.2012
You need to use strcmp to compare texts
pawn Код:
if(strcmp(race, "MDrag") == 0)
else if(strcmp(race, "MDrift") == 0)
https://sampwiki.blast.hk/wiki/Strcmp
Re: problem with stock function -
Niko_boy - 02.06.2012
you cant use
i.e. u cant compare string like that
use strcmp for it....
e.g
pawn Код:
if(!strcmp(race,"MDrag",true)) //
{
//code goes here
}
Re: problem with stock function -
niels44 - 02.06.2012
ah XD thnx


, i thought i could use it with if's etc, anyways thnx


:

and REP+ for both cuz of teh fast help
