SA-MP Forums Archive
i need some 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: i need some help (/showthread.php?tid=266499)



i need some help - HayZatic - 05.07.2011

okay for my script
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2 || newstate == 3)
    {
        new VehicleID = GetPlayerVehicleID(playerid);
        if(VehicleID == Vehicle_01)
        {
            new Name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Name, sizeof(Name));
            if(strcmp( Name, "HayZatic")) RemovePlayerFromVehicle(playerid);
            if(strcmp( Name, "HayZatic")) SendClientMessage(0xFFFF2AFF,"Welcome HayZatic");
I want it to say Welcome HayZatic For ONLY HayZatic No One Else. How do i do so?


Re: i need some help - Bakr - 05.07.2011

strcmp function returns 0 if the strings match. So change this
pawn Код:
if(strcmp( Name, "HayZatic")) SendClientMessage(0xFFFF2AFF,"Welcome HayZatic");
to
pawn Код:
if(!strcmp( Name, "HayZatic")) SendClientMessage(0xFFFF2AFF,"Welcome HayZatic");



Re: i need some help - HayZatic - 05.07.2011

Quote:
Originally Posted by Bakr
Посмотреть сообщение
strcmp function returns 0 if the strings match. So change this
pawn Код:
if(strcmp( Name, "HayZatic")) SendClientMessage(0xFFFF2AFF,"Welcome HayZatic");
to
pawn Код:
if(!strcmp( Name, "HayZatic")) SendClientMessage(0xFFFF2AFF,"Welcome HayZatic");
So Your Telling me If the Arguments are Matching it Goes Off By The 1?

Also, i get the error

Код:
error 035: argument type mismatch (argument 2)



Re: i need some help - Bakr - 05.07.2011

If the arguments are matching, the function will return a value of zero. The operator ! is equal to false, which is 0.

You need to add the playerid parameter to SendClientMessage function.


Re: i need some help - Shadoww5 - 05.07.2011

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == || newstate == 3)
    {
        new 
VehicleID GetPlayerVehicleID(playerid);
        if(
VehicleID == Vehicle_01)
        {
            new 
Name[MAX_PLAYER_NAME];
            
GetPlayerName(playeridNamesizeof(Name));
            if(
strcmpName"HayZatic") == 0) { SendClientMessage(playerid0xFFFF2AFF,"Welcome HayZatic"); } 
            else { 
RemovePlayerFromVehicle(playerid); }
        }
    }
    return 
1;