i need some help
#1

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

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");
Reply
#3

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)
Reply
#4

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.
Reply
#5

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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)