problem with stock function
#1

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

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

you cant use
Код:
if(race == "MDrag")
i.e. u cant compare string like that
use strcmp for it....
e.g
pawn Код:
if(!strcmp(race,"MDrag",true)) //
{
 //code goes here
}
Reply
#4

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

and REP+ for both cuz of teh fast help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)